From 1572e3514afcefc9eb2c34ec12d3e51d34a7f248 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Fri, 26 Apr 2019 03:01:34 +0200 Subject: [PATCH 01/20] my stuff --- VRChatApi/TestClient/App.config | 6 +++ .../TestClient/Properties/AssemblyInfo.cs | 36 +++++++++++++++ .../VRChatApi/Classes/FavoritesResponse.cs | 20 +++++++++ VRChatApi/VRChatApi/Classes/WorldResponse.cs | 16 +------ VRChatApi/VRChatApi/Endpoints/AvatarApi.cs | 45 +++++++++++++++++++ VRChatApi/VRChatApi/Endpoints/FavoritesAPI.cs | 32 +++++++++++++ .../VRChatApi/Properties/AssemblyInfo.cs | 1 + VRChatApi/VRChatApi/Utils.cs | 12 +++++ VRChatApi/VRChatApi/packages.config | 5 +++ 9 files changed, 159 insertions(+), 14 deletions(-) create mode 100644 VRChatApi/TestClient/App.config create mode 100644 VRChatApi/TestClient/Properties/AssemblyInfo.cs create mode 100644 VRChatApi/VRChatApi/Classes/FavoritesResponse.cs create mode 100644 VRChatApi/VRChatApi/Endpoints/FavoritesAPI.cs create mode 100644 VRChatApi/VRChatApi/Properties/AssemblyInfo.cs create mode 100644 VRChatApi/VRChatApi/Utils.cs create mode 100644 VRChatApi/VRChatApi/packages.config diff --git a/VRChatApi/TestClient/App.config b/VRChatApi/TestClient/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/VRChatApi/TestClient/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/VRChatApi/TestClient/Properties/AssemblyInfo.cs b/VRChatApi/TestClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d753e44 --- /dev/null +++ b/VRChatApi/TestClient/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TestClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TestClient")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("51e73a81-edc2-4790-90ca-38de49ff20c9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/VRChatApi/VRChatApi/Classes/FavoritesResponse.cs b/VRChatApi/VRChatApi/Classes/FavoritesResponse.cs new file mode 100644 index 0000000..2882a27 --- /dev/null +++ b/VRChatApi/VRChatApi/Classes/FavoritesResponse.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VRChatApi.Classes +{ + public class FavoritesResponse + { + public string id { get; set; } + public string type { get; set; } + public string favoriteId { get; set; } + public string[] tags { get; set; } + } + public enum FavoriteType + { + + } +} diff --git a/VRChatApi/VRChatApi/Classes/WorldResponse.cs b/VRChatApi/VRChatApi/Classes/WorldResponse.cs index e3ae0d6..c2cebcb 100644 --- a/VRChatApi/VRChatApi/Classes/WorldResponse.cs +++ b/VRChatApi/VRChatApi/Classes/WorldResponse.cs @@ -15,7 +15,7 @@ public class UnityPackage public string assetUrl { get; set; } public string pluginUrl { get; set; } public string unityVersion { get; set; } - public int unitySortNumber { get; set; } + public long unitySortNumber { get; set; } public int assetVersion { get; set; } public string platform { get; set; } [JsonProperty(PropertyName = "created_at")] @@ -28,22 +28,13 @@ public class WorldInstance public int occupants { get; set; } } - public class WorldResponse + public class WorldResponse : WorldBriefResponse { - public string id { get; set; } - public string name { get; set; } public string description { get; set; } public bool featured { get; set; } public string authorId { get; set; } - public string authorName { get; set; } - public int totalLikes { get; set; } - public int totalVisits { get; set; } public short capacity { get; set; } public List tags { get; set; } - [JsonConverter(typeof(StringEnumConverter))] - public ReleaseStatus releaseStatus { get; set; } - public string imageUrl { get; set; } - public string thumbnailImageUrl { get; set; } public string assetUrl { get; set; } public string pluginUrl { get; set; } public string unityPackageUrl { get; set; } @@ -51,14 +42,11 @@ public class WorldResponse public string nameSpace { get; set; } // Unknown public bool unityPackageUpdated { get; set; } // Unknown public List unityPackages { get; set; } - public bool isSecure { get; set; } // Unknown public bool isLockdown { get; set; } // Unknown public int version { get; set; } - public string organization { get; set; } // Unknown [JsonProperty(PropertyName = "instances")] public List _instances { get; set; } [JsonIgnore] public List instances { get; set; } - public int occupants { get; set; } } } diff --git a/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs b/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs index 820c4fe..de902a6 100644 --- a/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs @@ -31,5 +31,50 @@ public async Task GetById(string id) return res; } + + public async Task> Personal() + { + HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars?apiKey={Global.ApiKey}&releaseStatus=all&user=me"); + List res = null; + if (response.IsSuccessStatusCode) + { + var json = await response.Content.ReadAsStringAsync(); + Logger.Debug(() => $"JSON received: {json}"); + + res = JsonConvert.DeserializeObject>(json); + } + + return res; + } + + public async Task> List() + { + HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars?apiKey={Global.ApiKey}"); + List res = null; + if (response.IsSuccessStatusCode) + { + var json = await response.Content.ReadAsStringAsync(); + Logger.Debug(() => $"JSON received: {json}"); + + res = JsonConvert.DeserializeObject>(json); + } + + return res; + } + + public async Task> Favorites() + { + HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars/favorites?apiKey={Global.ApiKey}"); + List res = null; + if (response.IsSuccessStatusCode) + { + var json = await response.Content.ReadAsStringAsync(); + Logger.Debug(() => $"JSON received: {json}"); + + res = JsonConvert.DeserializeObject>(json); + } + + return res; + } } } diff --git a/VRChatApi/VRChatApi/Endpoints/FavoritesAPI.cs b/VRChatApi/VRChatApi/Endpoints/FavoritesAPI.cs new file mode 100644 index 0000000..f0a84c2 --- /dev/null +++ b/VRChatApi/VRChatApi/Endpoints/FavoritesAPI.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using VRChatApi.Classes; +using VRChatApi.Logging; + +namespace VRChatApi.Endpoints +{ + public class FavoritesAPI + { + private static readonly ILog Logger = LogProvider.GetCurrentClassLogger(); + public async Task> Get(string type = null) + { + bool hasType = (type != null); + HttpResponseMessage response = await Global.HttpClient.GetAsync($"favorites?apiKey={Global.ApiKey}{(hasType ? $"&type={type}":"")}"); + List res = null; + if (response.IsSuccessStatusCode) + { + var json = await response.Content.ReadAsStringAsync(); + Logger.Debug(() => $"JSON received: {json}"); + + res = JsonConvert.DeserializeObject>(json); + } + + return res; + } + } +} diff --git a/VRChatApi/VRChatApi/Properties/AssemblyInfo.cs b/VRChatApi/VRChatApi/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/VRChatApi/VRChatApi/Properties/AssemblyInfo.cs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/VRChatApi/VRChatApi/Utils.cs b/VRChatApi/VRChatApi/Utils.cs new file mode 100644 index 0000000..284b6df --- /dev/null +++ b/VRChatApi/VRChatApi/Utils.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VRChatApi +{ + class Utils + { + } +} diff --git a/VRChatApi/VRChatApi/packages.config b/VRChatApi/VRChatApi/packages.config new file mode 100644 index 0000000..374f45c --- /dev/null +++ b/VRChatApi/VRChatApi/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From 3fe99a23dae932ce93b9dbedf0b2f31b944813b8 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Sat, 27 Apr 2019 18:15:02 +0200 Subject: [PATCH 02/20] update repo --- .gitignore | 2 + VRChatApi/VRChatApi/Classes/AvatarResponse.cs | 2 +- VRChatApi/VRChatApi/Classes/Response.cs | 37 +++++++++++++++++++ .../VRChatApi/Classes/UserBriefResponse.cs | 2 +- VRChatApi/VRChatApi/Endpoints/FriendsApi.cs | 7 ++-- VRChatApi/VRChatApi/Endpoints/UserApi.cs | 4 ++ 6 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 VRChatApi/VRChatApi/Classes/Response.cs diff --git a/.gitignore b/.gitignore index 940794e..5cce309 100644 --- a/.gitignore +++ b/.gitignore @@ -286,3 +286,5 @@ __pycache__/ *.btm.cs *.odx.cs *.xsd.cs + +push.bat \ No newline at end of file diff --git a/VRChatApi/VRChatApi/Classes/AvatarResponse.cs b/VRChatApi/VRChatApi/Classes/AvatarResponse.cs index 614958d..2c4f6f3 100644 --- a/VRChatApi/VRChatApi/Classes/AvatarResponse.cs +++ b/VRChatApi/VRChatApi/Classes/AvatarResponse.cs @@ -6,7 +6,7 @@ namespace VRChatApi.Classes { - public class AvatarResponse + public class AvatarResponse : Response { public string id { get; set; } public string name { get; set; } diff --git a/VRChatApi/VRChatApi/Classes/Response.cs b/VRChatApi/VRChatApi/Classes/Response.cs new file mode 100644 index 0000000..c35f0c2 --- /dev/null +++ b/VRChatApi/VRChatApi/Classes/Response.cs @@ -0,0 +1,37 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace VRChatApi.Classes +{ + public class Response + { + public object Content { get; set; } + public StatusMessage Status { get; set; } + public class StatusMessage + { + public string Message { get; set; } + public System.Net.HttpStatusCode StatusCode { get; set; } + public StatusMessage(string message, int statusCode) + { + Message = message; + StatusCode = (System.Net.HttpStatusCode)statusCode; + } + } + } + public class BanResponse : Response + { + public bool Banned { get { return (Reason != null) ? true : false; } } + public string Reason { get; set; } + [JsonProperty(PropertyName = "expires")] + private string _expires { get; set; } + [JsonIgnore] + public DateTime Expires { get { return Convert.ToDateTime(_expires); } } + public BanResponse(string reason, string expires) + { + Reason = reason; + // Expires = Convert.ToDateTime(_expires); + } + } +} diff --git a/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs b/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs index fc12710..1fb2fbe 100644 --- a/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs +++ b/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs @@ -2,7 +2,7 @@ namespace VRChatApi.Classes { - public class UserBriefResponse + public class UserBriefResponse : Response { public string id { get; set; } public string username { get; set; } diff --git a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs index d81eed7..2614348 100644 --- a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs @@ -14,19 +14,20 @@ public class FriendsApi { private static readonly ILog Logger = LogProvider.GetCurrentClassLogger(); - public async Task> Get(int offset = 0, int count = 20, bool offline = false) + public async Task Get(int offset = 0, int count = 100, bool offline = false) { Logger.Debug(() => $"Getting friends with {nameof(offset)} = {offset}, {nameof(count)} = {count}, {nameof(offline)} = {offline}"); HttpResponseMessage response = await Global.HttpClient.GetAsync($"auth/user/friends?apiKey={Global.ApiKey}&offset={offset}&n={count}&offline={offline.ToString().ToLowerInvariant()}"); - List res = null; + BanResponse res = null; if (response.IsSuccessStatusCode) { var json = await response.Content.ReadAsStringAsync(); Logger.Debug(() => $"JSON received: {json}"); - res = JsonConvert.DeserializeObject>(json); + try { res = JsonConvert.DeserializeObject(json); } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } + try { res.Content = JsonConvert.DeserializeObject>(json); } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } } return res; diff --git a/VRChatApi/VRChatApi/Endpoints/UserApi.cs b/VRChatApi/VRChatApi/Endpoints/UserApi.cs index 5fd15d3..f18a626 100644 --- a/VRChatApi/VRChatApi/Endpoints/UserApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/UserApi.cs @@ -36,7 +36,11 @@ public async Task Login() { string json = await response.Content.ReadAsStringAsync(); Logger.Debug(() => $"JSON received: {json}"); + try { res = JsonConvert.DeserializeObject(json); + } catch { + res = (UserResponse)JsonConvert.DeserializeObject(json); + } } return res; From ca8a66bf72c04feec4f42dbc0a2116999f7f03d0 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Sun, 28 Apr 2019 04:17:07 +0200 Subject: [PATCH 03/20] update repo --- VRChatApi/VRChatApi/Classes/AvatarResponse.cs | 3 +- VRChatApi/VRChatApi/Classes/Response.cs | 38 ++++++++++--------- .../VRChatApi/Classes/UserBriefResponse.cs | 8 +++- VRChatApi/VRChatApi/Classes/UserResponse.cs | 5 +++ VRChatApi/VRChatApi/Endpoints/FriendsApi.cs | 8 ++-- VRChatApi/VRChatApi/Endpoints/UserApi.cs | 17 ++++----- VRChatApi/VRChatApi/VRChatApi.cs | 13 +++++++ 7 files changed, 57 insertions(+), 35 deletions(-) diff --git a/VRChatApi/VRChatApi/Classes/AvatarResponse.cs b/VRChatApi/VRChatApi/Classes/AvatarResponse.cs index 2c4f6f3..3b8d4fa 100644 --- a/VRChatApi/VRChatApi/Classes/AvatarResponse.cs +++ b/VRChatApi/VRChatApi/Classes/AvatarResponse.cs @@ -6,7 +6,7 @@ namespace VRChatApi.Classes { - public class AvatarResponse : Response + public class AvatarResponse : ErrorResponse { public string id { get; set; } public string name { get; set; } @@ -23,6 +23,5 @@ public class AvatarResponse : Response public List unityPackages { get; set; } public bool unityPackageUpdated { get; set; } public string unityPackageUrl { get; set; } - } } diff --git a/VRChatApi/VRChatApi/Classes/Response.cs b/VRChatApi/VRChatApi/Classes/Response.cs index c35f0c2..7fe8738 100644 --- a/VRChatApi/VRChatApi/Classes/Response.cs +++ b/VRChatApi/VRChatApi/Classes/Response.cs @@ -8,30 +8,32 @@ namespace VRChatApi.Classes public class Response { public object Content { get; set; } - public StatusMessage Status { get; set; } - public class StatusMessage + public object Status { get; set; } + public Response(object content, object status) { + Content = content; Status = status; + } + } + public class ErrorResponse + { + public ErrorMessage Error { get; set; } + public class ErrorMessage { public string Message { get; set; } - public System.Net.HttpStatusCode StatusCode { get; set; } - public StatusMessage(string message, int statusCode) - { - Message = message; - StatusCode = (System.Net.HttpStatusCode)statusCode; - } + public int status_code { get; set; } + [JsonIgnore] + public System.Net.HttpStatusCode StatusCode { get { return (System.Net.HttpStatusCode)status_code; } } } } - public class BanResponse : Response + public class BanResponse : ErrorResponse { - public bool Banned { get { return (Reason != null) ? true : false; } } + [JsonIgnore] + public bool Banned { get { return (ExpiresAt < DateTime.Now) ? true : false; } } + public string Target { get; set; } public string Reason { get; set; } - [JsonProperty(PropertyName = "expires")] - private string _expires { get; set; } + public string Expires { get; set; } [JsonIgnore] - public DateTime Expires { get { return Convert.ToDateTime(_expires); } } - public BanResponse(string reason, string expires) - { - Reason = reason; - // Expires = Convert.ToDateTime(_expires); - } + public DateTime ExpiresAt { get { return Convert.ToDateTime(Expires); } } + [JsonIgnore] + public TimeSpan ExpiresIn { get { return ExpiresAt - DateTime.Now; } } } } diff --git a/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs b/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs index 1fb2fbe..e99990f 100644 --- a/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs +++ b/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs @@ -1,8 +1,10 @@ -using System.Collections.Generic; +using Newtonsoft.Json; +using System.Collections.Generic; +using System.Net.Http; namespace VRChatApi.Classes { - public class UserBriefResponse : Response + public class UserBriefResponse { public string id { get; set; } public string username { get; set; } @@ -16,5 +18,7 @@ public class UserBriefResponse : Response public string location { get; set; } public string worldId { get; set; } public string instanceId { get; set; } + [JsonIgnore] + public HttpResponseMessage Raw { get; set; } } } diff --git a/VRChatApi/VRChatApi/Classes/UserResponse.cs b/VRChatApi/VRChatApi/Classes/UserResponse.cs index c92cb78..bfcb837 100644 --- a/VRChatApi/VRChatApi/Classes/UserResponse.cs +++ b/VRChatApi/VRChatApi/Classes/UserResponse.cs @@ -1,5 +1,7 @@ +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Collections.Generic; +using System.Net.Http; namespace VRChatApi.Classes { @@ -27,5 +29,8 @@ public class UserResponse : UserBriefResponse public JObject steamDetails { get; set; } public bool hasLoggedInFromClient { get; set; } public string authToken { get; set; } + /*public UserResponse(HttpResponseMessage raw = null) { + if (raw != null) Raw = raw; + }*/ } } diff --git a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs index 2614348..a4bf035 100644 --- a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs @@ -14,20 +14,20 @@ public class FriendsApi { private static readonly ILog Logger = LogProvider.GetCurrentClassLogger(); - public async Task Get(int offset = 0, int count = 100, bool offline = false) + public async Task> Get(int offset = 0, int count = 100, bool offline = false) { Logger.Debug(() => $"Getting friends with {nameof(offset)} = {offset}, {nameof(count)} = {count}, {nameof(offline)} = {offline}"); HttpResponseMessage response = await Global.HttpClient.GetAsync($"auth/user/friends?apiKey={Global.ApiKey}&offset={offset}&n={count}&offline={offline.ToString().ToLowerInvariant()}"); - BanResponse res = null; + List res = null; if (response.IsSuccessStatusCode) { var json = await response.Content.ReadAsStringAsync(); Logger.Debug(() => $"JSON received: {json}"); - try { res = JsonConvert.DeserializeObject(json); } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } - try { res.Content = JsonConvert.DeserializeObject>(json); } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } + // try { res = JsonConvert.DeserializeObject(json); } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } + try { res = JsonConvert.DeserializeObject>(json); } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } } return res; diff --git a/VRChatApi/VRChatApi/Endpoints/UserApi.cs b/VRChatApi/VRChatApi/Endpoints/UserApi.cs index f18a626..0d98729 100644 --- a/VRChatApi/VRChatApi/Endpoints/UserApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/UserApi.cs @@ -29,21 +29,17 @@ public async Task Login() { Logger.Trace(() => "Getting current user details"); HttpResponseMessage response = await Global.HttpClient.GetAsync($"auth/user?apiKey={Global.ApiKey}"); - UserResponse res = null; - if (response.IsSuccessStatusCode) { string json = await response.Content.ReadAsStringAsync(); Logger.Debug(() => $"JSON received: {json}"); - try { res = JsonConvert.DeserializeObject(json); - } catch { - res = (UserResponse)JsonConvert.DeserializeObject(json); - } } - - return res; + UserResponse result = new UserResponse(); + result.Raw = response; + if (res != null) result = res; + return result; } public async Task Register(string username, string password, string email, string birthday = null, string acceptedTOSVersion = null) @@ -124,7 +120,10 @@ public async Task UpdateInfo(string userId, string email = null, s HttpResponseMessage response = await Global.HttpClient.PutAsync($"users/{userId}?apiKey={Global.ApiKey}", content); - UserResponse res = null; + UserResponse res = new UserResponse(); + res.Raw = response; + + // res = await VRChatApi.ParseResponseAsync(response); if (response.IsSuccessStatusCode) { diff --git a/VRChatApi/VRChatApi/VRChatApi.cs b/VRChatApi/VRChatApi/VRChatApi.cs index 9819c4e..bf2b171 100644 --- a/VRChatApi/VRChatApi/VRChatApi.cs +++ b/VRChatApi/VRChatApi/VRChatApi.cs @@ -51,5 +51,18 @@ public VRChatApi(string username, string password) header.Add("Authorization", $"Basic {authEncoded}"); Logger.Trace(() => $"Added new Authorization header"); } + + /*public static async System.Threading.Tasks.Task ParseResponseAsync(HttpResponseMessage response, Type Class = null) + { + Object theObject = Activator.CreateInstance(Class); + var test = new Class(); + if (response.IsSuccessStatusCode) + { + var receivedJson = await response.Content.ReadAsStringAsync(); + Logger.Debug(() => $"JSON received: {receivedJson}"); + res = JsonConvert.DeserializeObject(receivedJson); + } + return theObject; + }*/ } } From 32bdc42c1ffa12e2865bceea51e811ded454f445 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Sun, 28 Apr 2019 08:09:16 +0200 Subject: [PATCH 04/20] update repo --- .../VRChatApi/Classes/NotificationResponse.cs | 24 ++++++++------ VRChatApi/VRChatApi/Endpoints/FriendsApi.cs | 24 +++++++++++++- .../VRChatApi/Endpoints/NotificationsAPI.cs | 32 +++++++++++++++++++ VRChatApi/VRChatApi/Endpoints/UserApi.cs | 16 ++++++++++ VRChatApi/VRChatApi/VRChatApi.cs | 2 ++ 5 files changed, 88 insertions(+), 10 deletions(-) create mode 100644 VRChatApi/VRChatApi/Endpoints/NotificationsAPI.cs diff --git a/VRChatApi/VRChatApi/Classes/NotificationResponse.cs b/VRChatApi/VRChatApi/Classes/NotificationResponse.cs index a4595a6..c5fa140 100644 --- a/VRChatApi/VRChatApi/Classes/NotificationResponse.cs +++ b/VRChatApi/VRChatApi/Classes/NotificationResponse.cs @@ -7,17 +7,23 @@ namespace VRChatApi.Classes { public class NotificationResponse { - public string id { get; set; } - public string type { get; set; } - public string senderUserId { get; set; } - public string receiverUserId { get; set; } - public string message { get; set; } - public JObject details { get; set; } // unknown - public string jobName { get; set; } - public string jobColor { get; set; } + public string Id { get; set; } + public bool Seen { get; set; } + public string Type { get; set; } + public string SenderUserId { get; set; } + public string SenderUsername { get; set; } + public string ReceiverUserId { get; set; } + public string Message { get; set; } + public string Details { get; set; } // unknown + public string JobName { get; set; } + public string JobColor { get; set; } + [JsonProperty(PropertyName = "created_at")] + public string Created { get; set; } + [JsonIgnore] + public DateTime CreatedAt { get { return Convert.ToDateTime(Created); } } [Obsolete("Typoed property, use receiverUserId instead")] [JsonIgnore] - public string recieverUserId { get => receiverUserId; set => receiverUserId = value; } + public string recieverUserId { get => ReceiverUserId; set => ReceiverUserId = value; } } } diff --git a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs index a4bf035..b04a207 100644 --- a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json; using VRChatApi.Classes; using VRChatApi.Logging; +using System; namespace VRChatApi.Endpoints { @@ -33,7 +34,7 @@ public async Task> Get(int offset = 0, int count = 100, return res; } - public async Task SendRequest(string userId, string fromWho) + public async Task SendNotification(string userId, string fromWho) { Logger.Debug(() => $"Sending friend request to {userId} from {fromWho}"); JObject json = new JObject(); @@ -61,6 +62,27 @@ public async Task SendRequest(string userId, string fromWh return res; } + public async Task SendRequest(string userId) + { + JObject json = new JObject(); + json["type"] = "friendrequest"; + json["message"] = $"Me wants to be your friend"; + Logger.Debug(() => $"Prepared JSON to post: {json}"); + StringContent content = new StringContent(json.ToString(), Encoding.UTF8); + content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + HttpResponseMessage response = await Global.HttpClient.PostAsync($"user/{userId}/friendRequest?apiKey={Global.ApiKey}", content); + NotificationResponse res = null; + + if (response.IsSuccessStatusCode) + { + var receivedJson = await response.Content.ReadAsStringAsync(); + Console.WriteLine($"FriendsApi.SendRequest JSON received: {receivedJson}"); + res = JsonConvert.DeserializeObject(receivedJson); + } + + return res; + } + // TODO: proper return type, need to document public async Task DeleteFriend(string userId) { diff --git a/VRChatApi/VRChatApi/Endpoints/NotificationsAPI.cs b/VRChatApi/VRChatApi/Endpoints/NotificationsAPI.cs new file mode 100644 index 0000000..d7c72ce --- /dev/null +++ b/VRChatApi/VRChatApi/Endpoints/NotificationsAPI.cs @@ -0,0 +1,32 @@ +using Newtonsoft.Json.Linq; +using System.Collections.Generic; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using VRChatApi.Classes; +using VRChatApi.Logging; +using System; + +namespace VRChatApi.Endpoints +{ + public class NotificationsAPI + { + private static readonly ILog Logger = LogProvider.GetCurrentClassLogger(); + public async Task> GetAll(string type = "all", bool sent = false, DateTime? after = null) + { + var url = $"auth/user/notifications?apiKey={Global.ApiKey}&type={type}&sent={sent}"; + if (after != null) url += $"&after={after}"; + HttpResponseMessage response = await Global.HttpClient.GetAsync(url); + List res = null; + if (response.IsSuccessStatusCode) + { + var receivedJson = await response.Content.ReadAsStringAsync(); + Console.WriteLine($"JSON received: {receivedJson}"); + res = JsonConvert.DeserializeObject>(receivedJson); + } + return res; + } + } +} diff --git a/VRChatApi/VRChatApi/Endpoints/UserApi.cs b/VRChatApi/VRChatApi/Endpoints/UserApi.cs index 0d98729..9b1f7b4 100644 --- a/VRChatApi/VRChatApi/Endpoints/UserApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/UserApi.cs @@ -78,6 +78,22 @@ public async Task Register(string username, string password, strin return res; } + public async Task> Search(string pattern, int limit = 100, int offset = 0) + { + HttpResponseMessage response = await Global.HttpClient.GetAsync($"users/?apiKey={Global.ApiKey}&n={limit}&offset={offset}&search={pattern}"); + + List res = null; + + if (response.IsSuccessStatusCode) + { + string json = await response.Content.ReadAsStringAsync(); + Logger.Debug(() => $"JSON received: {json}"); + res = JsonConvert.DeserializeObject>(json); + } + + return res; + } + public async Task GetById(string userId) { Logger.Debug(() => $"Getting user info with ID: {userId}"); diff --git a/VRChatApi/VRChatApi/VRChatApi.cs b/VRChatApi/VRChatApi/VRChatApi.cs index bf2b171..2029244 100644 --- a/VRChatApi/VRChatApi/VRChatApi.cs +++ b/VRChatApi/VRChatApi/VRChatApi.cs @@ -16,6 +16,7 @@ public class VRChatApi public WorldApi WorldApi { get; set; } public ModerationsApi ModerationsApi { get; set; } public AvatarApi AvatarApi { get; set; } + public NotificationsAPI NotificationsAPI { get; set; } public VRChatApi(string username, string password) { @@ -29,6 +30,7 @@ public VRChatApi(string username, string password) WorldApi = new WorldApi(); ModerationsApi = new ModerationsApi(); AvatarApi = new AvatarApi(); + NotificationsAPI = new NotificationsAPI(); // initialize http client // TODO: use the auth cookie From eafdfe745f16f16e41e76b14b9e90e2557e16883 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Mon, 29 Apr 2019 06:50:06 +0200 Subject: [PATCH 05/20] update repo --- .../VRChatApi/Endpoints/ModerationsApi.cs | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs b/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs index a18d5d7..0f58585 100644 --- a/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs @@ -2,9 +2,11 @@ using System.Collections.Generic; using System.Linq; using System.Net.Http; +using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using VRChatApi.Classes; using VRChatApi.Logging; @@ -17,7 +19,7 @@ public class ModerationsApi public async Task> GetPlayerModerations() { Logger.Trace(() => "Get list of moderations made by current user"); - HttpResponseMessage response = await Global.HttpClient.GetAsync("auth/user/playermoderations"); + HttpResponseMessage response = await Global.HttpClient.GetAsync($"auth/user/playermoderations?apiKey={Global.ApiKey}"); List res = null; @@ -34,7 +36,7 @@ public async Task> GetPlayerModerations() public async Task> GetPlayerModerated() { Logger.Trace(() => "Get list of moderations made against current user"); - HttpResponseMessage response = await Global.HttpClient.GetAsync("auth/user/playermoderated"); + HttpResponseMessage response = await Global.HttpClient.GetAsync($"auth/user/playermoderated?apiKey={Global.ApiKey}"); List res = null; @@ -47,5 +49,38 @@ public async Task> GetPlayerModerated() return res; } + + + public async Task BlockUser(string userId) + { + JObject json = new JObject(); + json["blocked"] = userId; + Logger.Debug(() => $"Prepared JSON to post: {json}"); + StringContent content = new StringContent(json.ToString(), Encoding.UTF8); + content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + HttpResponseMessage response = await Global.HttpClient.PostAsync($"auth/user/blocks?apiKey={Global.ApiKey}", content); + NotificationResponse res = null; + if (response.IsSuccessStatusCode) + { + var receivedJson = await response.Content.ReadAsStringAsync(); + Logger.Debug(() => $"JSON received: {receivedJson}"); + res = JsonConvert.DeserializeObject(receivedJson); + } + return res; + } + + public async Task UnblockUser(string userId, string modId) + { + HttpResponseMessage response = await Global.HttpClient.DeleteAsync($"user/{userId}/moderations/{modId}?apiKey={Global.ApiKey}"); + string res = ""; + if (response.IsSuccessStatusCode) + { + var json = await response.Content.ReadAsStringAsync(); + Logger.Debug(() => $"JSON received: {json}"); + res = json; + } + return res; + } + } } From 868e89aed5033e0d3debd20df5bfc5f0f5d3fcbf Mon Sep 17 00:00:00 2001 From: Bluscream Date: Thu, 2 May 2019 22:37:05 +0200 Subject: [PATCH 06/20] update repo --- VRChatApi/VRChatApi/Classes/AvatarResponse.cs | 2 +- VRChatApi/VRChatApi/Classes/Response.cs | 42 +++++++++++++------ .../VRChatApi/Endpoints/ModerationsApi.cs | 19 ++++----- VRChatApi/VRChatApi/Endpoints/UserApi.cs | 38 +---------------- 4 files changed, 41 insertions(+), 60 deletions(-) diff --git a/VRChatApi/VRChatApi/Classes/AvatarResponse.cs b/VRChatApi/VRChatApi/Classes/AvatarResponse.cs index 3b8d4fa..b923012 100644 --- a/VRChatApi/VRChatApi/Classes/AvatarResponse.cs +++ b/VRChatApi/VRChatApi/Classes/AvatarResponse.cs @@ -6,7 +6,7 @@ namespace VRChatApi.Classes { - public class AvatarResponse : ErrorResponse + public class AvatarResponse { public string id { get; set; } public string name { get; set; } diff --git a/VRChatApi/VRChatApi/Classes/Response.cs b/VRChatApi/VRChatApi/Classes/Response.cs index 7fe8738..f75f807 100644 --- a/VRChatApi/VRChatApi/Classes/Response.cs +++ b/VRChatApi/VRChatApi/Classes/Response.cs @@ -1,7 +1,9 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.Net.Http; using System.Text; +using System.Threading.Tasks; namespace VRChatApi.Classes { @@ -9,22 +11,38 @@ public class Response { public object Content { get; set; } public object Status { get; set; } - public Response(object content, object status) { - Content = content; Status = status; + public HttpResponseMessage Raw { get; set; } + public async Task FromResponseMessageAsync(HttpResponseMessage response) { // , object content = null + // if (content != null) Content = content; + if (response != null) { + Raw = response; + string json = await response.Content.ReadAsStringAsync(); + try { Status = JsonConvert.DeserializeObject(json); + } catch { Status = JsonConvert.DeserializeObject(json); } + } + return this; } } - public class ErrorResponse + public class Message { - public ErrorMessage Error { get; set; } - public class ErrorMessage - { - public string Message { get; set; } - public int status_code { get; set; } - [JsonIgnore] - public System.Net.HttpStatusCode StatusCode { get { return (System.Net.HttpStatusCode)status_code; } } - } + [JsonProperty(PropertyName = "message")] + public string _message { get; set; } + [JsonIgnore] + public string Content { get { return _message; } } + public int status_code { get; set; } + [JsonIgnore] + public System.Net.HttpStatusCode StatusCode { get { return (System.Net.HttpStatusCode)status_code; } } + } + + public class Success + { + public Message success { get; set; } + } + public class Error + { + public Message error { get; set; } } - public class BanResponse : ErrorResponse + public class BanResponse : Error { [JsonIgnore] public bool Banned { get { return (ExpiresAt < DateTime.Now) ? true : false; } } diff --git a/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs b/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs index 0f58585..88180e5 100644 --- a/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs @@ -69,18 +69,17 @@ public async Task BlockUser(string userId) return res; } - public async Task UnblockUser(string userId, string modId) + public async Task UnblockUser(string userId) { - HttpResponseMessage response = await Global.HttpClient.DeleteAsync($"user/{userId}/moderations/{modId}?apiKey={Global.ApiKey}"); - string res = ""; - if (response.IsSuccessStatusCode) - { - var json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - res = json; - } + JObject json_out = new JObject(); + json_out["moderated "] = userId; + json_out["type"] = "block"; + Console.WriteLine($"Prepared JSON to put: {json_out}"); + StringContent content = new StringContent(json_out.ToString(), Encoding.UTF8); + content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + HttpResponseMessage response = await Global.HttpClient.PutAsync($"auth/user/unplayermoderate?apiKey={Global.ApiKey}", content); + Response res = await new Response().FromResponseMessageAsync(response); return res; } - } } diff --git a/VRChatApi/VRChatApi/Endpoints/UserApi.cs b/VRChatApi/VRChatApi/Endpoints/UserApi.cs index 9b1f7b4..d35d9ba 100644 --- a/VRChatApi/VRChatApi/Endpoints/UserApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/UserApi.cs @@ -8,23 +8,19 @@ using System.Threading.Tasks; using VRChatApi.Classes; using VRChatApi.Logging; - namespace VRChatApi.Endpoints { public class UserApi { private static readonly ILog Logger = LogProvider.GetCurrentClassLogger(); - public string Username { get; set; } public string Password { get; set; } - public UserApi(string username, string password) { Logger.Trace(() => $"Entering {nameof(UserApi)} constructor with username: {username}"); Username = username; Password = password; } - public async Task Login() { Logger.Trace(() => "Getting current user details"); @@ -41,114 +37,82 @@ public async Task Login() if (res != null) result = res; return result; } - public async Task Register(string username, string password, string email, string birthday = null, string acceptedTOSVersion = null) { Logger.Debug(() => $"Registering new user with {nameof(username)} = {username}, {nameof(email)} = {email}, {nameof(birthday)} = {birthday}, {nameof(acceptedTOSVersion)} = {acceptedTOSVersion}"); JObject json = new JObject(); json["username"] = username; json["password"] = password; - if (email != null) json["email"] = email; - if (birthday != null ) json["birthday"] = birthday; - if (acceptedTOSVersion != null) json["acceptedTOSVersion"] = acceptedTOSVersion; - Logger.Debug(() => $"Prepared JSON to post: {json}"); - StringContent content = new StringContent(json.ToString(), Encoding.UTF8); - content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); - HttpResponseMessage response = await Global.HttpClient.PostAsync($"auth/register?apiKey={Global.ApiKey}", content); - UserResponse res = null; - if (response.IsSuccessStatusCode) { var receivedJson = await response.Content.ReadAsStringAsync(); Logger.Debug(() => $"JSON received: {receivedJson}"); res = JsonConvert.DeserializeObject(receivedJson); } - return res; } - public async Task> Search(string pattern, int limit = 100, int offset = 0) { HttpResponseMessage response = await Global.HttpClient.GetAsync($"users/?apiKey={Global.ApiKey}&n={limit}&offset={offset}&search={pattern}"); - List res = null; - if (response.IsSuccessStatusCode) { string json = await response.Content.ReadAsStringAsync(); Logger.Debug(() => $"JSON received: {json}"); res = JsonConvert.DeserializeObject>(json); } - return res; } - public async Task GetById(string userId) { Logger.Debug(() => $"Getting user info with ID: {userId}"); HttpResponseMessage response = await Global.HttpClient.GetAsync($"users/{userId}?apiKey={Global.ApiKey}"); - UserBriefResponse res = null; - if (response.IsSuccessStatusCode) { string json = await response.Content.ReadAsStringAsync(); Logger.Debug(() => $"JSON received: {json}"); res = JsonConvert.DeserializeObject(json); } - return res; } - public async Task UpdateInfo(string userId, string email = null, string birthday = null, string acceptedTOSVersion = null, List tags = null) { Logger.Debug(() => $"Updating user info for {nameof(userId)} = {userId} with {nameof(email)} = {email}, {nameof(birthday)} = {birthday}, {nameof(acceptedTOSVersion)} = {acceptedTOSVersion}, {nameof(tags)} = {tags}"); JObject json = new JObject(); - if (email != null) json["email"] = email; - if (birthday != null) json["birthday"] = birthday; - if (acceptedTOSVersion != null) json["acceptedTOSVersion"] = acceptedTOSVersion; - if (tags != null) json["tags"] = JToken.FromObject(tags); - Logger.Debug(() => $"Prepared JSON to put: {json}"); - StringContent content = new StringContent(json.ToString(), Encoding.UTF8); - content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); - HttpResponseMessage response = await Global.HttpClient.PutAsync($"users/{userId}?apiKey={Global.ApiKey}", content); - UserResponse res = new UserResponse(); res.Raw = response; - // res = await VRChatApi.ParseResponseAsync(response); - if (response.IsSuccessStatusCode) { var receivedJson = await response.Content.ReadAsStringAsync(); Logger.Debug(() => $"JSON received: {receivedJson}"); res = JsonConvert.DeserializeObject(receivedJson); } - return res; } } -} +} \ No newline at end of file From cc6141bbc21caf107235a92b968818eafa7b97a9 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Sat, 25 May 2019 10:16:28 +0200 Subject: [PATCH 07/20] update repo --- .../VRChatApi/Classes/NotificationResponse.cs | 16 +++++++--- VRChatApi/VRChatApi/Endpoints/FriendsApi.cs | 30 +++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/VRChatApi/VRChatApi/Classes/NotificationResponse.cs b/VRChatApi/VRChatApi/Classes/NotificationResponse.cs index c5fa140..f7d55b2 100644 --- a/VRChatApi/VRChatApi/Classes/NotificationResponse.cs +++ b/VRChatApi/VRChatApi/Classes/NotificationResponse.cs @@ -5,25 +5,33 @@ namespace VRChatApi.Classes { + public class NotificationDetails + { + public string WorldId { get; set; } + public string WorldName { get; set; } + } public class NotificationResponse { public string Id { get; set; } - public bool Seen { get; set; } public string Type { get; set; } public string SenderUserId { get; set; } public string SenderUsername { get; set; } public string ReceiverUserId { get; set; } public string Message { get; set; } - public string Details { get; set; } // unknown - public string JobName { get; set; } - public string JobColor { get; set; } + public NotificationDetails Details { get; set; } // unknown [JsonProperty(PropertyName = "created_at")] public string Created { get; set; } [JsonIgnore] public DateTime CreatedAt { get { return Convert.ToDateTime(Created); } } + public string JobName { get; set; } + public string JobColor { get; set; } [Obsolete("Typoed property, use receiverUserId instead")] [JsonIgnore] public string recieverUserId { get => ReceiverUserId; set => ReceiverUserId = value; } } + public class NotificationResponseWithSeen : NotificationResponse + { + public bool Seen { get; set; } + } } diff --git a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs index b04a207..420565e 100644 --- a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs @@ -114,5 +114,35 @@ public async Task AcceptFriend(string userId) return res;*/ } + + public async Task SendMessage(string userId, string message, string hiddenMessage = "") + { + JObject json = new JObject(); + json["type"] = "invite"; + json["message"] = hiddenMessage; + json["details"] = new JObject(); + json["details"]["worldId"] = ""; + json["details"]["worldName"] = message; + + Logger.Debug(() => $"Prepared JSON to post: {json}"); + + StringContent content = new StringContent(json.ToString(), Encoding.UTF8); + + content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + + HttpResponseMessage response = await Global.HttpClient.PostAsync($"user/{userId}/notification?apiKey={Global.ApiKey}", content); + + + NotificationResponse res = null; + + if (response.IsSuccessStatusCode) + { + var receivedJson = await response.Content.ReadAsStringAsync(); + Logger.Debug(() => $"JSON received: {receivedJson}"); + res = JsonConvert.DeserializeObject(receivedJson); + } + + return res; + } } } From 9f92962ee52359c747c04ccb0f26b8662afb22cf Mon Sep 17 00:00:00 2001 From: Bluscream Date: Mon, 10 Jun 2019 23:57:21 +0200 Subject: [PATCH 08/20] update repo --- VRChatApi/VRChatApi/Classes/NotificationResponse.cs | 6 +++++- VRChatApi/VRChatApi/Endpoints/FriendsApi.cs | 13 +++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/VRChatApi/VRChatApi/Classes/NotificationResponse.cs b/VRChatApi/VRChatApi/Classes/NotificationResponse.cs index f7d55b2..3b56f62 100644 --- a/VRChatApi/VRChatApi/Classes/NotificationResponse.cs +++ b/VRChatApi/VRChatApi/Classes/NotificationResponse.cs @@ -18,7 +18,7 @@ public class NotificationResponse public string SenderUsername { get; set; } public string ReceiverUserId { get; set; } public string Message { get; set; } - public NotificationDetails Details { get; set; } // unknown + public string Details { get; set; } // unknown [JsonProperty(PropertyName = "created_at")] public string Created { get; set; } [JsonIgnore] @@ -30,6 +30,10 @@ public class NotificationResponse [JsonIgnore] public string recieverUserId { get => ReceiverUserId; set => ReceiverUserId = value; } } + public class NotificationResponseWithDetails : NotificationResponse + { + public NotificationDetails Details { get; set; } + } public class NotificationResponseWithSeen : NotificationResponse { public bool Seen { get; set; } diff --git a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs index 420565e..c859ad8 100644 --- a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs @@ -115,8 +115,7 @@ public async Task AcceptFriend(string userId) return res;*/ } - public async Task SendMessage(string userId, string message, string hiddenMessage = "") - { + public async Task SendMessage(string userId, string message, string hiddenMessage = "") { JObject json = new JObject(); json["type"] = "invite"; json["message"] = hiddenMessage; @@ -124,22 +123,24 @@ public async Task SendMessage(string userId, string messag json["details"]["worldId"] = ""; json["details"]["worldName"] = message; - Logger.Debug(() => $"Prepared JSON to post: {json}"); + Console.WriteLine($"Prepared JSON to post: {json}"); StringContent content = new StringContent(json.ToString(), Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + Console.WriteLine($"Prepared StringContent to post: {content}"); + HttpResponseMessage response = await Global.HttpClient.PostAsync($"user/{userId}/notification?apiKey={Global.ApiKey}", content); - NotificationResponse res = null; + NotificationResponseWithDetails res = null; if (response.IsSuccessStatusCode) { var receivedJson = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {receivedJson}"); - res = JsonConvert.DeserializeObject(receivedJson); + Console.WriteLine($"JSON received: {receivedJson}"); + res = JsonConvert.DeserializeObject(receivedJson); } return res; From b45e1cc8992ae799e79d3e09fc4a92626b3a15cd Mon Sep 17 00:00:00 2001 From: Bluscream Date: Sat, 15 Jun 2019 20:30:52 +0200 Subject: [PATCH 09/20] update repo --- VRChatApi/VRChatApi/Endpoints/FriendsApi.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs index c859ad8..1f704a5 100644 --- a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs @@ -48,7 +48,7 @@ public async Task SendNotification(string userId, string f content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await Global.HttpClient.PostAsync($"user/{userId}/notification?apiKey={Global.ApiKey}", content); - + NotificationResponse res = null; @@ -115,13 +115,14 @@ public async Task AcceptFriend(string userId) return res;*/ } - public async Task SendMessage(string userId, string message, string hiddenMessage = "") { + public async Task SendInvite(string userId, string worldInstanceId = "", string worldName = "my world", string hiddenMessage = "") + { JObject json = new JObject(); json["type"] = "invite"; json["message"] = hiddenMessage; json["details"] = new JObject(); - json["details"]["worldId"] = ""; - json["details"]["worldName"] = message; + json["details"]["worldId"] = worldInstanceId; + json["details"]["worldName"] = worldName; Console.WriteLine($"Prepared JSON to post: {json}"); @@ -132,7 +133,7 @@ public async Task SendMessage(string userId, st Console.WriteLine($"Prepared StringContent to post: {content}"); HttpResponseMessage response = await Global.HttpClient.PostAsync($"user/{userId}/notification?apiKey={Global.ApiKey}", content); - + NotificationResponseWithDetails res = null; @@ -145,5 +146,7 @@ public async Task SendMessage(string userId, st return res; } + + public async Task SendMessage(string userId, string message, string hiddenMessage = "") => await SendInvite(userId, worldName: message, hiddenMessage: hiddenMessage); } } From 60fbbc5ccf6fa066c9f3b401d8ff583839de51ea Mon Sep 17 00:00:00 2001 From: Bluscream Date: Thu, 11 Jul 2019 07:24:53 +0200 Subject: [PATCH 10/20] update repo --- VRChatApi/VRChatApi/Classes/UserBriefResponse.cs | 2 ++ VRChatApi/VRChatApi/Endpoints/AvatarApi.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs b/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs index e99990f..0b6c055 100644 --- a/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs +++ b/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs @@ -6,6 +6,8 @@ namespace VRChatApi.Classes { public class UserBriefResponse { + [JsonIgnore] + public bool Offline { get; set; } public string id { get; set; } public string username { get; set; } public string displayName { get; set; } diff --git a/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs b/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs index de902a6..76ec207 100644 --- a/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs @@ -64,7 +64,7 @@ public async Task> List() public async Task> Favorites() { - HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars/favorites?apiKey={Global.ApiKey}"); + HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars/favorites?apiKey={Global.ApiKey}?n=16"); List res = null; if (response.IsSuccessStatusCode) { From 9184eb8fdae546439014c39b5fe1b6203b020e48 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Thu, 11 Jul 2019 07:29:52 +0200 Subject: [PATCH 11/20] update repo --- VRChatApi/VRChatApi/Endpoints/AvatarApi.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs b/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs index 76ec207..1dfcb70 100644 --- a/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs @@ -34,7 +34,7 @@ public async Task GetById(string id) public async Task> Personal() { - HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars?apiKey={Global.ApiKey}&releaseStatus=all&user=me"); + HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars?apiKey={Global.ApiKey}&releaseStatus=all&user=me&n=100"); List res = null; if (response.IsSuccessStatusCode) { @@ -64,7 +64,7 @@ public async Task> List() public async Task> Favorites() { - HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars/favorites?apiKey={Global.ApiKey}?n=16"); + HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars/favorites?apiKey={Global.ApiKey}&n=16"); List res = null; if (response.IsSuccessStatusCode) { From 7a0e38050c2bbfe4e97b68dd2eac1a12b28fe108 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Thu, 25 Jul 2019 12:30:14 +0200 Subject: [PATCH 12/20] update repo --- VRChatApi/VRChatApi/Classes/ConfigResponse.cs | 113 ++++++++++++------ .../VRChatApi/Classes/UserBriefResponse.cs | 34 ++++++ VRChatApi/VRChatApi/Endpoints/UserApi.cs | 8 +- 3 files changed, 116 insertions(+), 39 deletions(-) diff --git a/VRChatApi/VRChatApi/Classes/ConfigResponse.cs b/VRChatApi/VRChatApi/Classes/ConfigResponse.cs index 6442a0e..79f9a72 100644 --- a/VRChatApi/VRChatApi/Classes/ConfigResponse.cs +++ b/VRChatApi/VRChatApi/Classes/ConfigResponse.cs @@ -2,42 +2,81 @@ namespace VRChatApi.Classes { - public class ConfigResponse + public class DynamicWorldRow { - public string messageOfTheDay { get; set; } - public string timeOutWorldId { get; set; } - public string gearDemoRoomId { get; set; } - public string releaseServerVersionStandalone { get; set; } - public string downloadLinkWindows { get; set; } - public string releaseAppVersionStandalone { get; set; } - public string devAppVersionStandalone { get; set; } - public string devDownloadLinkWindows { get; set; } - public int currentTOSVersion { get; set; } - public string releaseSdkUrl { get; set; } - public string releaseSdkVersion { get; set; } - public string devSdkUrl { get; set; } - public string devSdkVersion { get; set; } - public List whiteListedAssetUrls { get; set; } - public string clientApiKey { get; set; } - public string viveWindowsUrl { get; set; } - public string sdkUnityVersion { get; set; } - public string hubWorldId { get; set; } - public string homeWorldId { get; set; } - public string tutorialWorldId { get; set; } - public bool disableEventStream { get; set; } - public bool disableAvatarGating { get; set; } - public List registrationShitList { get; set; } - public string plugin { get; set; } - public string address { get; set; } - public string contactEmail { get; set; } - public string supportEmail { get; set; } - public string jobsEmail { get; set; } - public string copyrightEmail { get; set; } - public string moderationEmail { get; set; } - public string appName { get; set; } - public string serverName { get; set; } - public string deploymentGroup { get; set; } - public string buildVersionTag { get; set; } - public string apiKey { get; set; } + public string name { get; set; } + public string sortHeading { get; set; } + public string sortOwnership { get; set; } + public string sortOrder { get; set; } + public string platform { get; set; } + public int index { get; set; } + public string tag { get; set; } + } + + public class Announcement + { + public string name { get; set; } + public string text { get; set; } + } + + public class ConfigResponse + { + public string messageOfTheDay { get; set; } + public string timeOutWorldId { get; set; } + public string gearDemoRoomId { get; set; } + public string releaseServerVersionStandalone { get; set; } + public string downloadLinkWindows { get; set; } + public string releaseAppVersionStandalone { get; set; } + public string devAppVersionStandalone { get; set; } + public string devServerVersionStandalone { get; set; } + public string devDownloadLinkWindows { get; set; } + public int currentTOSVersion { get; set; } + public string releaseSdkUrl { get; set; } + public string releaseSdkVersion { get; set; } + public string devSdkUrl { get; set; } + public string devSdkVersion { get; set; } + public List whiteListedAssetUrls { get; set; } + public string clientApiKey { get; set; } + public string viveWindowsUrl { get; set; } + public string sdkUnityVersion { get; set; } + public string hubWorldId { get; set; } + public string homeWorldId { get; set; } + public string tutorialWorldId { get; set; } + public bool disableEventStream { get; set; } + public bool disableAvatarGating { get; set; } + public bool disableFeedbackGating { get; set; } + public bool disableRegistration { get; set; } + public bool disableUpgradeAccount { get; set; } + public bool disableCommunityLabs { get; set; } + public bool disableCommunityLabsPromotion { get; set; } + public bool disableTwoFactorAuth { get; set; } + public bool disableSteamNetworking { get; set; } + public string plugin { get; set; } + public string sdkNotAllowedToPublishMessage { get; set; } + public string sdkDeveloperFaqUrl { get; set; } + public string sdkDiscordUrl { get; set; } + public string notAllowedToSelectAvatarInPrivateWorldMessage { get; set; } + public int userVerificationTimeout { get; set; } + public int userUpdatePeriod { get; set; } + public int userVerificationDelay { get; set; } + public int userVerificationRetry { get; set; } + public int worldUpdatePeriod { get; set; } + public int moderationQueryPeriod { get; set; } + public string defaultAvatar { get; set; } + public List dynamicWorldRows { get; set; } + public bool disableAvatarCopying { get; set; } + public List announcements { get; set; } + public string address { get; set; } + public string contactEmail { get; set; } + public string supportEmail { get; set; } + public string jobsEmail { get; set; } + public string copyrightEmail { get; set; } + public string moderationEmail { get; set; } + public bool disableEmail { get; set; } + public string appName { get; set; } + public string serverName { get; set; } + public string deploymentGroup { get; set; } + public string buildVersionTag { get; set; } + public string apiKey { get; set; } + } } -} diff --git a/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs b/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs index 0b6c055..e830ddf 100644 --- a/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs +++ b/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs @@ -4,6 +4,40 @@ namespace VRChatApi.Classes { + public class UserStatus + { + public enum Status + { + Unknown, Offline, Busy, Active, JoinMe + } + public Status FromString(string status) + { + switch (status.ToLowerInvariant()) + { + case "join me": + return Status.JoinMe; + case "active": + return Status.Active; + case "busy": + return Status.Busy; + case "offline": + return Status.Offline; + default: + return Status.Unknown; + } + } + public string ToString(Status status) + { + switch (status) + { + case Status.Offline: return "offline"; + case Status.Busy: return "busy"; + case Status.Active: return "active"; + case Status.JoinMe: return "join me"; + default: return ""; + } + } + } public class UserBriefResponse { [JsonIgnore] diff --git a/VRChatApi/VRChatApi/Endpoints/UserApi.cs b/VRChatApi/VRChatApi/Endpoints/UserApi.cs index d35d9ba..9dbb4cc 100644 --- a/VRChatApi/VRChatApi/Endpoints/UserApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/UserApi.cs @@ -87,9 +87,9 @@ public async Task GetById(string userId) } return res; } - public async Task UpdateInfo(string userId, string email = null, string birthday = null, string acceptedTOSVersion = null, List tags = null) + public async Task UpdateInfo(string userId, string email = null, string birthday = null, string acceptedTOSVersion = null, List tags = null, string status = null, string statusDescription = null) { - Logger.Debug(() => $"Updating user info for {nameof(userId)} = {userId} with {nameof(email)} = {email}, {nameof(birthday)} = {birthday}, {nameof(acceptedTOSVersion)} = {acceptedTOSVersion}, {nameof(tags)} = {tags}"); + Logger.Debug(() => $"Updating user info for {nameof(userId)} = {userId} with {nameof(email)} = {email}, {nameof(birthday)} = {birthday}, {nameof(acceptedTOSVersion)} = {acceptedTOSVersion}, {nameof(tags)} = {tags}, {nameof(status)} = {status}, {nameof(statusDescription)} = {statusDescription}"); JObject json = new JObject(); if (email != null) json["email"] = email; @@ -99,6 +99,10 @@ public async Task UpdateInfo(string userId, string email = null, s json["acceptedTOSVersion"] = acceptedTOSVersion; if (tags != null) json["tags"] = JToken.FromObject(tags); + if (status != null) + json["status"] = status; + if (statusDescription != null) + json["statusDescription"] = statusDescription; Logger.Debug(() => $"Prepared JSON to put: {json}"); StringContent content = new StringContent(json.ToString(), Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); From 6433ff706079459749dea419c54b6cb71f95d350 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Sat, 10 Aug 2019 05:03:56 +0200 Subject: [PATCH 13/20] update repo --- VRChatApi/VRChatApi/Classes/AvatarResponse.cs | 35 ++++- VRChatApi/VRChatApi/Classes/ConfigResponse.cs | 124 +++++++++--------- .../VRChatApi/Classes/FavoritesResponse.cs | 5 +- .../VRChatApi/Classes/FavouriteResponse.cs | 14 ++ .../VRChatApi/Classes/NotificationResponse.cs | 20 ++- .../Classes/PlayerModeratedResponse.cs | 6 +- VRChatApi/VRChatApi/Classes/Response.cs | 8 +- .../VRChatApi/Classes/UserBriefResponse.cs | 18 +-- VRChatApi/VRChatApi/Classes/UserResponse.cs | 42 ++++-- .../VRChatApi/Classes/WorldBriefResponse.cs | 27 ++-- VRChatApi/VRChatApi/Classes/WorldEnums.cs | 10 +- .../Classes/WorldInstanceResponse.cs | 11 +- .../Classes/WorldInstanceUserResponse.cs | 2 +- .../Classes/WorldMetadataResponse.cs | 82 +++++++++++- VRChatApi/VRChatApi/Classes/WorldResponse.cs | 28 +--- VRChatApi/VRChatApi/Endpoints/AvatarApi.cs | 66 ++-------- VRChatApi/VRChatApi/Endpoints/FavouriteApi.cs | 46 +++++++ VRChatApi/VRChatApi/Endpoints/FriendsApi.cs | 116 ++++------------ .../VRChatApi/Endpoints/ModerationsApi.cs | 57 +++----- VRChatApi/VRChatApi/Endpoints/RemoteConfig.cs | 18 +-- VRChatApi/VRChatApi/Endpoints/UserApi.cs | 116 +++++++--------- VRChatApi/VRChatApi/Endpoints/WorldAPI.cs | 67 +++++----- VRChatApi/VRChatApi/Utils.cs | 77 ++++++++++- VRChatApi/VRChatApi/VRChatApi.cs | 18 +-- VRChatApi/VRChatApi/VRChatApi.csproj | 3 +- 25 files changed, 543 insertions(+), 473 deletions(-) create mode 100644 VRChatApi/VRChatApi/Classes/FavouriteResponse.cs create mode 100644 VRChatApi/VRChatApi/Endpoints/FavouriteApi.cs diff --git a/VRChatApi/VRChatApi/Classes/AvatarResponse.cs b/VRChatApi/VRChatApi/Classes/AvatarResponse.cs index b923012..74d5f7c 100644 --- a/VRChatApi/VRChatApi/Classes/AvatarResponse.cs +++ b/VRChatApi/VRChatApi/Classes/AvatarResponse.cs @@ -1,12 +1,33 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; + +#pragma warning disable IDE1006 namespace VRChatApi.Classes { - public class AvatarResponse + public class AssetUrlObject + { + } + + public class UnityPackage + { + public string id { get; set; } + public string assetUrl { get; set; } + public AssetUrlObject assetUrlObject { get; set; } + public string unityVersion { get; set; } + public long unitySortNumber { get; set; } + public int assetVersion { get; set; } + public string platform { get; set; } + public DateTime created_at { get; set; } + } + + public class UnityPackageUrlObject + { + public string unityPackageUrl { get; set; } + } + + public class AvatarResponse : Response { public string id { get; set; } public string name { get; set; } @@ -15,6 +36,7 @@ public class AvatarResponse public string authorName { get; set; } public List tags { get; set; } public string assetUrl { get; set; } + public AssetUrlObject assetUrlObject { get; set; } public string imageUrl { get; set; } public string thumbnailImageUrl { get; set; } public string releaseStatus { get; set; } @@ -23,5 +45,8 @@ public class AvatarResponse public List unityPackages { get; set; } public bool unityPackageUpdated { get; set; } public string unityPackageUrl { get; set; } + public UnityPackageUrlObject unityPackageUrlObject { get; set; } + public DateTime created_at { get; set; } + public DateTime updated_at { get; set; } } } diff --git a/VRChatApi/VRChatApi/Classes/ConfigResponse.cs b/VRChatApi/VRChatApi/Classes/ConfigResponse.cs index 79f9a72..bc6c3c1 100644 --- a/VRChatApi/VRChatApi/Classes/ConfigResponse.cs +++ b/VRChatApi/VRChatApi/Classes/ConfigResponse.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +using Newtonsoft.Json; +using System.Collections.Generic; + +#pragma warning disable IDE1006 namespace VRChatApi.Classes { @@ -19,64 +22,65 @@ public class Announcement public string text { get; set; } } - public class ConfigResponse + public class ConfigResponse : Response { - public string messageOfTheDay { get; set; } - public string timeOutWorldId { get; set; } - public string gearDemoRoomId { get; set; } - public string releaseServerVersionStandalone { get; set; } - public string downloadLinkWindows { get; set; } - public string releaseAppVersionStandalone { get; set; } - public string devAppVersionStandalone { get; set; } - public string devServerVersionStandalone { get; set; } - public string devDownloadLinkWindows { get; set; } - public int currentTOSVersion { get; set; } - public string releaseSdkUrl { get; set; } - public string releaseSdkVersion { get; set; } - public string devSdkUrl { get; set; } - public string devSdkVersion { get; set; } - public List whiteListedAssetUrls { get; set; } - public string clientApiKey { get; set; } - public string viveWindowsUrl { get; set; } - public string sdkUnityVersion { get; set; } - public string hubWorldId { get; set; } - public string homeWorldId { get; set; } - public string tutorialWorldId { get; set; } - public bool disableEventStream { get; set; } - public bool disableAvatarGating { get; set; } - public bool disableFeedbackGating { get; set; } - public bool disableRegistration { get; set; } - public bool disableUpgradeAccount { get; set; } - public bool disableCommunityLabs { get; set; } - public bool disableCommunityLabsPromotion { get; set; } - public bool disableTwoFactorAuth { get; set; } - public bool disableSteamNetworking { get; set; } - public string plugin { get; set; } - public string sdkNotAllowedToPublishMessage { get; set; } - public string sdkDeveloperFaqUrl { get; set; } - public string sdkDiscordUrl { get; set; } - public string notAllowedToSelectAvatarInPrivateWorldMessage { get; set; } - public int userVerificationTimeout { get; set; } - public int userUpdatePeriod { get; set; } - public int userVerificationDelay { get; set; } - public int userVerificationRetry { get; set; } - public int worldUpdatePeriod { get; set; } - public int moderationQueryPeriod { get; set; } - public string defaultAvatar { get; set; } - public List dynamicWorldRows { get; set; } - public bool disableAvatarCopying { get; set; } - public List announcements { get; set; } - public string address { get; set; } - public string contactEmail { get; set; } - public string supportEmail { get; set; } - public string jobsEmail { get; set; } - public string copyrightEmail { get; set; } - public string moderationEmail { get; set; } - public bool disableEmail { get; set; } - public string appName { get; set; } - public string serverName { get; set; } - public string deploymentGroup { get; set; } - public string buildVersionTag { get; set; } - public string apiKey { get; set; } - } + public string messageOfTheDay { get; set; } + public string timeOutWorldId { get; set; } + public string gearDemoRoomId { get; set; } + public string releaseServerVersionStandalone { get; set; } + public string downloadLinkWindows { get; set; } + public string releaseAppVersionStandalone { get; set; } + public string devAppVersionStandalone { get; set; } + public string devServerVersionStandalone { get; set; } + public string devDownloadLinkWindows { get; set; } + public int currentTOSVersion { get; set; } + public string releaseSdkUrl { get; set; } + public string releaseSdkVersion { get; set; } + public string devSdkUrl { get; set; } + public string devSdkVersion { get; set; } + public List whiteListedAssetUrls { get; set; } + public string clientApiKey { get; set; } + public string viveWindowsUrl { get; set; } + public string sdkUnityVersion { get; set; } + public string hubWorldId { get; set; } + public string homeWorldId { get; set; } + public string tutorialWorldId { get; set; } + public bool disableEventStream { get; set; } + public bool disableAvatarGating { get; set; } + public bool disableFeedbackGating { get; set; } + public bool disableRegistration { get; set; } + public bool disableUpgradeAccount { get; set; } + public bool disableCommunityLabs { get; set; } + public bool disableCommunityLabsPromotion { get; set; } + public bool disableTwoFactorAuth { get; set; } + public bool disableSteamNetworking { get; set; } + public string plugin { get; set; } + public string sdkNotAllowedToPublishMessage { get; set; } + public string sdkDeveloperFaqUrl { get; set; } + public string sdkDiscordUrl { get; set; } + public string notAllowedToSelectAvatarInPrivateWorldMessage { get; set; } + public int userVerificationTimeout { get; set; } + public int userUpdatePeriod { get; set; } + public int userVerificationDelay { get; set; } + public int userVerificationRetry { get; set; } + public int worldUpdatePeriod { get; set; } + public int moderationQueryPeriod { get; set; } + public int clientDisconnectTimeout { get; set; } + public string defaultAvatar { get; set; } + public List dynamicWorldRows { get; set; } + public bool disableAvatarCopying { get; set; } + public List announcements { get; set; } + public string address { get; set; } + public string contactEmail { get; set; } + public string supportEmail { get; set; } + public string jobsEmail { get; set; } + public string copyrightEmail { get; set; } + public string moderationEmail { get; set; } + public bool disableEmail { get; set; } + public string appName { get; set; } + public string serverName { get; set; } + public string deploymentGroup { get; set; } + public string buildVersionTag { get; set; } + public string apiKey { get; set; } } +} diff --git a/VRChatApi/VRChatApi/Classes/FavoritesResponse.cs b/VRChatApi/VRChatApi/Classes/FavoritesResponse.cs index 2882a27..fc60fe5 100644 --- a/VRChatApi/VRChatApi/Classes/FavoritesResponse.cs +++ b/VRChatApi/VRChatApi/Classes/FavoritesResponse.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +7,7 @@ namespace VRChatApi.Classes { - public class FavoritesResponse + public class FavoritesResponse : Response { public string id { get; set; } public string type { get; set; } diff --git a/VRChatApi/VRChatApi/Classes/FavouriteResponse.cs b/VRChatApi/VRChatApi/Classes/FavouriteResponse.cs new file mode 100644 index 0000000..295ca37 --- /dev/null +++ b/VRChatApi/VRChatApi/Classes/FavouriteResponse.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +#pragma warning disable IDE1006 + +namespace VRChatApi.Classes +{ + public class FavouriteResponse : Response + { + public string id { get; set; } + public string type { get; set; } + public string favoriteId { get; set; } + public List tags { get; set; } + } +} diff --git a/VRChatApi/VRChatApi/Classes/NotificationResponse.cs b/VRChatApi/VRChatApi/Classes/NotificationResponse.cs index 3b56f62..ab5ca1f 100644 --- a/VRChatApi/VRChatApi/Classes/NotificationResponse.cs +++ b/VRChatApi/VRChatApi/Classes/NotificationResponse.cs @@ -1,16 +1,19 @@ -using System; -using System.ComponentModel; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using System; + +#pragma warning disable IDE1006 namespace VRChatApi.Classes { public class NotificationDetails { public string WorldId { get; set; } + [JsonIgnore] + public bool rsvp { get; set; } public string WorldName { get; set; } } - public class NotificationResponse + + public class NotificationResponse : Response { public string Id { get; set; } public string Type { get; set; } @@ -18,17 +21,12 @@ public class NotificationResponse public string SenderUsername { get; set; } public string ReceiverUserId { get; set; } public string Message { get; set; } - public string Details { get; set; } // unknown + public NotificationDetails details { get; set; } [JsonProperty(PropertyName = "created_at")] public string Created { get; set; } - [JsonIgnore] public DateTime CreatedAt { get { return Convert.ToDateTime(Created); } } public string JobName { get; set; } public string JobColor { get; set; } - - [Obsolete("Typoed property, use receiverUserId instead")] - [JsonIgnore] - public string recieverUserId { get => ReceiverUserId; set => ReceiverUserId = value; } } public class NotificationResponseWithDetails : NotificationResponse { diff --git a/VRChatApi/VRChatApi/Classes/PlayerModeratedResponse.cs b/VRChatApi/VRChatApi/Classes/PlayerModeratedResponse.cs index fce2883..e4e3201 100644 --- a/VRChatApi/VRChatApi/Classes/PlayerModeratedResponse.cs +++ b/VRChatApi/VRChatApi/Classes/PlayerModeratedResponse.cs @@ -4,9 +4,11 @@ using System.Text; using System.Threading.Tasks; +#pragma warning disable IDE1006 + namespace VRChatApi.Classes { - public class PlayerModeratedResponse + public class PlayerModeratedResponse : Response { public string id { get; set; } public string type { get; set; } @@ -14,6 +16,6 @@ public class PlayerModeratedResponse public string sourceDisplayName { get; set; } public string targetUserId { get; set; } public string targetDisplayName { get; set; } - public string created { get; set; } + public DateTime created { get; set; } } } diff --git a/VRChatApi/VRChatApi/Classes/Response.cs b/VRChatApi/VRChatApi/Classes/Response.cs index f75f807..fce3082 100644 --- a/VRChatApi/VRChatApi/Classes/Response.cs +++ b/VRChatApi/VRChatApi/Classes/Response.cs @@ -9,9 +9,11 @@ namespace VRChatApi.Classes { public class Response { - public object Content { get; set; } - public object Status { get; set; } + + [JsonIgnore] public HttpResponseMessage Raw { get; set; } + /*public object Content { get; set; } + public object Status { get; set; } public async Task FromResponseMessageAsync(HttpResponseMessage response) { // , object content = null // if (content != null) Content = content; if (response != null) { @@ -21,7 +23,7 @@ public async Task FromResponseMessageAsync(HttpResponseMessage respons } catch { Status = JsonConvert.DeserializeObject(json); } } return this; - } + }*/ } public class Message { diff --git a/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs b/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs index e830ddf..4dc0498 100644 --- a/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs +++ b/VRChatApi/VRChatApi/Classes/UserBriefResponse.cs @@ -1,6 +1,7 @@ -using Newtonsoft.Json; -using System.Collections.Generic; -using System.Net.Http; +using System.Collections.Generic; +using Newtonsoft.Json; + +#pragma warning disable IDE1006 namespace VRChatApi.Classes { @@ -38,7 +39,7 @@ public string ToString(Status status) } } } - public class UserBriefResponse + public class UserBriefResponse : Response { [JsonIgnore] public bool Offline { get; set; } @@ -47,14 +48,13 @@ public class UserBriefResponse public string displayName { get; set; } public string currentAvatarImageUrl { get; set; } public string currentAvatarThumbnailImageUrl { get; set; } - public string developerType { get; set; } + public string last_platform { get; set; } public List tags { get; set; } + public string developerType { get; set; } public string status { get; set; } public string statusDescription { get; set; } + public string friendKey { get; set; } + public bool isFriend { get; set; } public string location { get; set; } - public string worldId { get; set; } - public string instanceId { get; set; } - [JsonIgnore] - public HttpResponseMessage Raw { get; set; } } } diff --git a/VRChatApi/VRChatApi/Classes/UserResponse.cs b/VRChatApi/VRChatApi/Classes/UserResponse.cs index bfcb837..c16cc55 100644 --- a/VRChatApi/VRChatApi/Classes/UserResponse.cs +++ b/VRChatApi/VRChatApi/Classes/UserResponse.cs @@ -1,36 +1,52 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; -using System.Net.Http; + +#pragma warning disable IDE1006 namespace VRChatApi.Classes { public class PastDisplayName { - string displayName { get; set; } - string updated_at { get; set; } + public string displayName { get; set; } + public DateTime updated_at { get; set; } + } + + public class SteamDetails + { + } + + public class Feature + { + public bool twoFactorAuth { get; set; } } public class UserResponse : UserBriefResponse { public List pastDisplayNames { get; set; } public bool hasEmail { get; set; } + public bool hasPendingEmail { get; set; } public string obfuscatedEmail { get; set; } + public string obfuscatedPendingEmail { get; set; } public bool emailVerified { get; set; } public bool hasBirthday { get; set; } public bool unsubscribe { get; set; } public List friends { get; set; } - public JObject blueprints { get; set; } - public JObject currentAvatarBlueprint { get; set; } - public List events { get; set; } + public List friendGroupNames { get; set; } public string currentAvatar { get; set; } public string currentAvatarAssetUrl { get; set; } public int acceptedTOSVersion { get; set; } - public JObject steamDetails { get; set; } + public string steamId { get; set; } + public SteamDetails steamDetails { get; set; } + public string oculusId { get; set; } public bool hasLoggedInFromClient { get; set; } - public string authToken { get; set; } - /*public UserResponse(HttpResponseMessage raw = null) { - if (raw != null) Raw = raw; - }*/ + public string homeLocation { get; set; } + public bool twoFactorAuthEnabled { get; set; } + public Feature feature { get; set; } + public string state { get; set; } + public DateTime last_login { get; set; } + public bool allowAvatarCopying { get; set; } + public List onlineFriends { get; set; } + public List activeFriends { get; set; } + public List offlineFriends { get; set; } } } diff --git a/VRChatApi/VRChatApi/Classes/WorldBriefResponse.cs b/VRChatApi/VRChatApi/Classes/WorldBriefResponse.cs index 8aa9154..eed6244 100644 --- a/VRChatApi/VRChatApi/Classes/WorldBriefResponse.cs +++ b/VRChatApi/VRChatApi/Classes/WorldBriefResponse.cs @@ -1,27 +1,36 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using Newtonsoft.Json.Converters; +#pragma warning disable IDE1006 + namespace VRChatApi.Classes { - public class WorldBriefResponse + public class WorldBriefResponse : Response { public string id { get; set; } public string name { get; set; } + public string authorId { get; set; } public string authorName { get; set; } - public int totalLikes { get; set; } - public int totalVisits { get; set; } + public int capacity { get; set; } public string imageUrl { get; set; } public string thumbnailImageUrl { get; set; } - public bool isSecure { get; set; } // Unknown + [JsonConverter(typeof(StringEnumConverter))] public ReleaseStatus releaseStatus { get; set; } - public string organization { get; set; } // Unknown + + public string organization { get; set; } + public List tags { get; set; } + public int favorites { get; set; } + public DateTime created_at { get; set; } + public DateTime updated_at { get; set; } + public DateTime publicationDate { get; set; } + public DateTime labsPublicationDate { get; set; } + public int visits { get; set; } + public List unityPackages { get; set; } + public int popularity { get; set; } + public int heat { get; set; } public int occupants { get; set; } } } diff --git a/VRChatApi/VRChatApi/Classes/WorldEnums.cs b/VRChatApi/VRChatApi/Classes/WorldEnums.cs index 52bf753..89cde54 100644 --- a/VRChatApi/VRChatApi/Classes/WorldEnums.cs +++ b/VRChatApi/VRChatApi/Classes/WorldEnums.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel; namespace VRChatApi.Classes { @@ -22,9 +18,13 @@ public enum SortOptions public enum ReleaseStatus { + [Description("public")] Public, + [Description("private")] Private, + [Description("all")] All, + [Description("hidden")] Hidden, } diff --git a/VRChatApi/VRChatApi/Classes/WorldInstanceResponse.cs b/VRChatApi/VRChatApi/Classes/WorldInstanceResponse.cs index af9f576..346b351 100644 --- a/VRChatApi/VRChatApi/Classes/WorldInstanceResponse.cs +++ b/VRChatApi/VRChatApi/Classes/WorldInstanceResponse.cs @@ -1,14 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; + +#pragma warning disable IDE1006 namespace VRChatApi.Classes { - public class WorldInstanceResponse + public class WorldInstanceResponse : Response { public string id { get; set; } public string name { get; set; } diff --git a/VRChatApi/VRChatApi/Classes/WorldInstanceUserResponse.cs b/VRChatApi/VRChatApi/Classes/WorldInstanceUserResponse.cs index bf0b33b..06fa857 100644 --- a/VRChatApi/VRChatApi/Classes/WorldInstanceUserResponse.cs +++ b/VRChatApi/VRChatApi/Classes/WorldInstanceUserResponse.cs @@ -8,7 +8,7 @@ namespace VRChatApi.Classes { - public class WorldInstanceUserResponse + public class WorldInstanceUserResponse : Response { public string id { get; set; } public string username { get; set; } diff --git a/VRChatApi/VRChatApi/Classes/WorldMetadataResponse.cs b/VRChatApi/VRChatApi/Classes/WorldMetadataResponse.cs index d343781..db60303 100644 --- a/VRChatApi/VRChatApi/Classes/WorldMetadataResponse.cs +++ b/VRChatApi/VRChatApi/Classes/WorldMetadataResponse.cs @@ -1,15 +1,85 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; + +#pragma warning disable IDE1006 namespace VRChatApi.Classes { - public class WorldMetadataResponse + public class EventPortal + { + public string eventName { get; set; } + public string worldId { get; set; } + public DateTime eventStartTimeUtc { get; set; } + public string eventDuration { get; set; } + } + + public class Metadata + { + public string CENTER_TEXT { get; set; } + public string CENTER_TEXT2 { get; set; } + public List PANOS { get; set; } + public List AVATAR_CUSTOM { get; set; } + public List AVATAR_FEATURED { get; set; } + public List AVATAR_HELP { get; set; } + public List AVATAR_MORPH { get; set; } + public List AVATAR_PEDESTAL { get; set; } + public List EVENTHALL_WELCOME { get; set; } + public List EVENTHAPPENING { get; set; } + public List EVENTS { get; set; } + public List MICROPHONE { get; set; } + public List PANOSPHERE { get; set; } + public List TIPS { get; set; } + public List WELCOME { get; set; } + public List WELCOME_2 { get; set; } + public List WORLD_CREATION { get; set; } + public List WORLD_FEATURED_ONE { get; set; } + public List WORLD_FEATURED_THREE { get; set; } + public List WORLD_FEATURED_TWO { get; set; } + public List WORLD_HELP { get; set; } + public List HELP_ROOM_1 { get; set; } + public List HELP_ROOM_2 { get; set; } + public List HELP_ROOM_3 { get; set; } + public List HELP_ROOM_4 { get; set; } + public List STAFF_PORTAL_1 { get; set; } + public string STAFF_CREATOR_1 { get; set; } + public List STAFF_IMAGE_1 { get; set; } + public List STAFF_PORTAL_2 { get; set; } + public string STAFF_CREATOR_2 { get; set; } + public List STAFF_IMAGE_2 { get; set; } + public List STAFF_PORTAL_3 { get; set; } + public string STAFF_CREATOR_3 { get; set; } + public List STAFF_IMAGE_3 { get; set; } + public string AVATAR_1 { get; set; } + public string AVATAR_2 { get; set; } + public string AVATAR_3 { get; set; } + public List EVENT_CALENDAR { get; set; } + public List LOCATION_SPAWN { get; set; } + public List HELP_WELCOME { get; set; } + public List AVATAR_WELCOME { get; set; } + public List NEW_WORLDS_WELCOME { get; set; } + public List FEATURED_WORLDS_WELCOME { get; set; } + public List EVENTHALL_MARQUEE { get; set; } + public List FOUNTAIN_WELCOME { get; set; } + public List EVENT_PORTAL { get; set; } + public List HELP_PORTAL_1 { get; set; } + public List HELP_PORTAL_2 { get; set; } + public bool NameplatesVisibleByDefault { get; set; } + public List HELP_PORTALS { get; set; } + public List EVENT_PORTAL_1 { get; set; } + public List EVENT_PORTAL_2 { get; set; } + public List EVENT_PORTAL_3 { get; set; } + public List EVENT_PORTAL_4 { get; set; } + public List AVATAR_PORTAL_1 { get; set; } + public List AVATAR_PORTAL_2 { get; set; } + public List AVATAR_STATIC_PORTAL_1 { get; set; } + public List AVATAR_STATIC_PORTAL_2 { get; set; } + public List FIREPIT_PORTAL_2 { get; set; } + public List FIREPIT_PORTAL_1 { get; set; } + } + + public class WorldMetadataResponse : Response { public string id { get; set; } - public JObject metadata { get; set; } + public Metadata metadata { get; set; } } } diff --git a/VRChatApi/VRChatApi/Classes/WorldResponse.cs b/VRChatApi/VRChatApi/Classes/WorldResponse.cs index c2cebcb..61e52a7 100644 --- a/VRChatApi/VRChatApi/Classes/WorldResponse.cs +++ b/VRChatApi/VRChatApi/Classes/WorldResponse.cs @@ -1,27 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Converters; +#pragma warning disable IDE1006 + namespace VRChatApi.Classes { - public class UnityPackage - { - public string id { get; set; } - public string assetUrl { get; set; } - public string pluginUrl { get; set; } - public string unityVersion { get; set; } - public long unitySortNumber { get; set; } - public int assetVersion { get; set; } - public string platform { get; set; } - [JsonProperty(PropertyName = "created_at")] - public string createdTime { get; set; } - } - public class WorldInstance { public string id { get; set; } @@ -32,16 +17,15 @@ public class WorldResponse : WorldBriefResponse { public string description { get; set; } public bool featured { get; set; } - public string authorId { get; set; } - public short capacity { get; set; } - public List tags { get; set; } + public int totalLikes { get; set; } + public int totalVisits { get; set; } public string assetUrl { get; set; } public string pluginUrl { get; set; } public string unityPackageUrl { get; set; } [JsonProperty(PropertyName = "namespace")] public string nameSpace { get; set; } // Unknown public bool unityPackageUpdated { get; set; } // Unknown - public List unityPackages { get; set; } + public bool isSecure { get; set; } // Unknown public bool isLockdown { get; set; } // Unknown public int version { get; set; } [JsonProperty(PropertyName = "instances")] diff --git a/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs b/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs index 1dfcb70..99f24dc 100644 --- a/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/AvatarApi.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using System.Net.Http; using System.Text; using System.Threading.Tasks; -using Newtonsoft.Json; using VRChatApi.Classes; using VRChatApi.Logging; @@ -17,64 +14,25 @@ public class AvatarApi public async Task GetById(string id) { Logger.Debug(() => $"Getting avatar details using ID: {id}"); - HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars/{id}?apiKey={Global.ApiKey}"); - - AvatarResponse res = null; - - if (response.IsSuccessStatusCode) - { - var json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - - res = JsonConvert.DeserializeObject(json); - } - return res; - } - - public async Task> Personal() - { - HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars?apiKey={Global.ApiKey}&releaseStatus=all&user=me&n=100"); - List res = null; - if (response.IsSuccessStatusCode) - { - var json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - - res = JsonConvert.DeserializeObject>(json); - } + HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars/{id}?apiKey={Global.ApiKey}"); - return res; + return await Utils.ParseResponse(response); } + public async Task> Personal(ReleaseStatus releaseStatus = ReleaseStatus.All, int amount = 100) => await List(releaseStatus: releaseStatus, amount: amount, user: "me"); - public async Task> List() + public async Task> List(ReleaseStatus releaseStatus = ReleaseStatus.All, int amount = 100, string user = null) { - HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars?apiKey={Global.ApiKey}"); - List res = null; - if (response.IsSuccessStatusCode) - { - var json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - - res = JsonConvert.DeserializeObject>(json); - } - - return res; + var sb = new StringBuilder(); + if (!string.IsNullOrEmpty(user)) sb.Append($"&user={user}"); + HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars?apiKey={Global.ApiKey}&releaseStatus={releaseStatus.GetDescription()}&n={amount}{sb.ToString()}"); + return await Utils.ParseResponse>(response); } - public async Task> Favorites() + public async Task> Favorites(int amount = 16) { - HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars/favorites?apiKey={Global.ApiKey}&n=16"); - List res = null; - if (response.IsSuccessStatusCode) - { - var json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - - res = JsonConvert.DeserializeObject>(json); - } - - return res; + HttpResponseMessage response = await Global.HttpClient.GetAsync($"avatars/favorites?apiKey={Global.ApiKey}&n={amount}"); + return await Utils.ParseResponse>(response); } } } diff --git a/VRChatApi/VRChatApi/Endpoints/FavouriteApi.cs b/VRChatApi/VRChatApi/Endpoints/FavouriteApi.cs new file mode 100644 index 0000000..a347ab2 --- /dev/null +++ b/VRChatApi/VRChatApi/Endpoints/FavouriteApi.cs @@ -0,0 +1,46 @@ +using Newtonsoft.Json.Linq; +using System.Collections.Generic; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; +using VRChatApi.Classes; + +namespace VRChatApi.Endpoints +{ + public class FavouriteApi + { + + public async Task FavouriteAvatar(string avatarId) + { + JObject json = new JObject() + { + { "type", "avatar" }, + { "favoriteId", avatarId }, + { "tags", new JArray(new[] { "avatars1" })} + }; + + StringContent content = new StringContent(json.ToString(), Encoding.UTF8); + + content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + + HttpResponseMessage response = await Global.HttpClient.PostAsync($"favorites?apiKey={Global.ApiKey}", content); + + return await Utils.ParseResponse(response); + } + + public async Task> GetFavourites(string favouriteType = "avatar") + { + HttpResponseMessage response = await Global.HttpClient.GetAsync($"favorites?type={favouriteType}&apiKey={Global.ApiKey}"); + + return await Utils.ParseResponse>(response); + } + + public async Task GetFavourite(string favouriteId) + { + HttpResponseMessage response = await Global.HttpClient.GetAsync($"favorites/{favouriteId}?apiKey={Global.ApiKey}"); + + return await Utils.ParseResponse(response); + } + } +} diff --git a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs index 1f704a5..2766304 100644 --- a/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/FriendsApi.cs @@ -4,10 +4,8 @@ using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; -using Newtonsoft.Json; using VRChatApi.Classes; using VRChatApi.Logging; -using System; namespace VRChatApi.Endpoints { @@ -15,31 +13,24 @@ public class FriendsApi { private static readonly ILog Logger = LogProvider.GetCurrentClassLogger(); - public async Task> Get(int offset = 0, int count = 100, bool offline = false) + public async Task> Get(int offset = 0, int count = 20, bool offline = false) { Logger.Debug(() => $"Getting friends with {nameof(offset)} = {offset}, {nameof(count)} = {count}, {nameof(offline)} = {offline}"); HttpResponseMessage response = await Global.HttpClient.GetAsync($"auth/user/friends?apiKey={Global.ApiKey}&offset={offset}&n={count}&offline={offline.ToString().ToLowerInvariant()}"); - List res = null; - - if (response.IsSuccessStatusCode) - { - var json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - // try { res = JsonConvert.DeserializeObject(json); } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } - try { res = JsonConvert.DeserializeObject>(json); } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } - } - - return res; + return await Utils.ParseResponse>(response); } - public async Task SendNotification(string userId, string fromWho) + public async Task SendRequest(string userId, string fromWho = "Me") { Logger.Debug(() => $"Sending friend request to {userId} from {fromWho}"); - JObject json = new JObject(); - json["type"] = "friendrequest"; - json["message"] = $"{fromWho} wants to be your friend"; + + JObject json = new JObject() + { + { "type", "friendrequest" }, + { "message", $"{fromWho} wants to be your friend" } + }; Logger.Debug(() => $"Prepared JSON to post: {json}"); @@ -49,102 +40,45 @@ public async Task SendNotification(string userId, string f HttpResponseMessage response = await Global.HttpClient.PostAsync($"user/{userId}/notification?apiKey={Global.ApiKey}", content); - - NotificationResponse res = null; - - if (response.IsSuccessStatusCode) - { - var receivedJson = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {receivedJson}"); - res = JsonConvert.DeserializeObject(receivedJson); - } - - return res; + return await Utils.ParseResponse(response); } - public async Task SendRequest(string userId) - { - JObject json = new JObject(); - json["type"] = "friendrequest"; - json["message"] = $"Me wants to be your friend"; - Logger.Debug(() => $"Prepared JSON to post: {json}"); - StringContent content = new StringContent(json.ToString(), Encoding.UTF8); - content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); - HttpResponseMessage response = await Global.HttpClient.PostAsync($"user/{userId}/friendRequest?apiKey={Global.ApiKey}", content); - NotificationResponse res = null; - - if (response.IsSuccessStatusCode) - { - var receivedJson = await response.Content.ReadAsStringAsync(); - Console.WriteLine($"FriendsApi.SendRequest JSON received: {receivedJson}"); - res = JsonConvert.DeserializeObject(receivedJson); - } - - return res; - } - - // TODO: proper return type, need to document - public async Task DeleteFriend(string userId) + public async Task DeleteFriend(string userId) { HttpResponseMessage response = await Global.HttpClient.DeleteAsync($"auth/user/friends/{userId}?apiKey={Global.ApiKey}"); - string res = ""; - - if (response.IsSuccessStatusCode) - { - var json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - res = json; - } - - return res; + return Utils.ParseResponse(response) != null; } - // TODO: proper return type, need to document - public async Task AcceptFriend(string userId) + public async Task AcceptFriend(string userId) { HttpResponseMessage response = await Global.HttpClient.PutAsync($"auth/user/notifications/{userId}/accept?apiKey={Global.ApiKey}", new StringContent("")); - /*string res = ""; - - if (response.IsSuccessStatusCode) - { - res = await response.Content.ReadAsStringAsync(); - } - - return res;*/ + return Utils.ParseResponse(response) != null; } public async Task SendInvite(string userId, string worldInstanceId = "", string worldName = "my world", string hiddenMessage = "") { - JObject json = new JObject(); - json["type"] = "invite"; - json["message"] = hiddenMessage; - json["details"] = new JObject(); - json["details"]["worldId"] = worldInstanceId; - json["details"]["worldName"] = worldName; + JObject json = new JObject() { + { "type", "invite" }, + { "message", hiddenMessage }, + { "details", new JObject() { + { "worldId", worldInstanceId }, + { "worldName", worldName } + }}, + }; - Console.WriteLine($"Prepared JSON to post: {json}"); + Logger.Debug(() => $"Prepared JSON to post: {json}"); StringContent content = new StringContent(json.ToString(), Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); - Console.WriteLine($"Prepared StringContent to post: {content}"); + Logger.Debug(() => $"Prepared StringContent to post: {content}"); HttpResponseMessage response = await Global.HttpClient.PostAsync($"user/{userId}/notification?apiKey={Global.ApiKey}", content); - - NotificationResponseWithDetails res = null; - - if (response.IsSuccessStatusCode) - { - var receivedJson = await response.Content.ReadAsStringAsync(); - Console.WriteLine($"JSON received: {receivedJson}"); - res = JsonConvert.DeserializeObject(receivedJson); - } - - return res; + return await Utils.ParseResponse(response); } public async Task SendMessage(string userId, string message, string hiddenMessage = "") => await SendInvite(userId, worldName: message, hiddenMessage: hiddenMessage); diff --git a/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs b/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs index 88180e5..f41f1eb 100644 --- a/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/ModerationsApi.cs @@ -1,12 +1,9 @@ -using System; +using Newtonsoft.Json.Linq; using System.Collections.Generic; -using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using VRChatApi.Classes; using VRChatApi.Logging; @@ -19,67 +16,45 @@ public class ModerationsApi public async Task> GetPlayerModerations() { Logger.Trace(() => "Get list of moderations made by current user"); - HttpResponseMessage response = await Global.HttpClient.GetAsync($"auth/user/playermoderations?apiKey={Global.ApiKey}"); - List res = null; + HttpResponseMessage response = await Global.HttpClient.GetAsync("auth/user/playermoderations"); - if (response.IsSuccessStatusCode) - { - var json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - res = JsonConvert.DeserializeObject>(json); - } - - return res; + return await Utils.ParseResponse>(response); } public async Task> GetPlayerModerated() { Logger.Trace(() => "Get list of moderations made against current user"); - HttpResponseMessage response = await Global.HttpClient.GetAsync($"auth/user/playermoderated?apiKey={Global.ApiKey}"); - - List res = null; - if (response.IsSuccessStatusCode) - { - var json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - res = JsonConvert.DeserializeObject>(json); - } + HttpResponseMessage response = await Global.HttpClient.GetAsync("auth/user/playermoderated"); - return res; + return await Utils.ParseResponse>(response); } public async Task BlockUser(string userId) { - JObject json = new JObject(); - json["blocked"] = userId; + JObject json = new JObject() { + { "blocked", userId } + }; Logger.Debug(() => $"Prepared JSON to post: {json}"); StringContent content = new StringContent(json.ToString(), Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await Global.HttpClient.PostAsync($"auth/user/blocks?apiKey={Global.ApiKey}", content); - NotificationResponse res = null; - if (response.IsSuccessStatusCode) - { - var receivedJson = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {receivedJson}"); - res = JsonConvert.DeserializeObject(receivedJson); - } - return res; + return await Utils.ParseResponse(response); } public async Task UnblockUser(string userId) { - JObject json_out = new JObject(); - json_out["moderated "] = userId; - json_out["type"] = "block"; - Console.WriteLine($"Prepared JSON to put: {json_out}"); - StringContent content = new StringContent(json_out.ToString(), Encoding.UTF8); + JObject json = new JObject() { + { "moderated", userId }, + { "type", "block" } + }; + Logger.Debug(() => $"Prepared JSON to put: {json}"); + StringContent content = new StringContent(json.ToString(), Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await Global.HttpClient.PutAsync($"auth/user/unplayermoderate?apiKey={Global.ApiKey}", content); - Response res = await new Response().FromResponseMessageAsync(response); - return res; + return await Utils.ParseResponse(response); } } } diff --git a/VRChatApi/VRChatApi/Endpoints/RemoteConfig.cs b/VRChatApi/VRChatApi/Endpoints/RemoteConfig.cs index 252ecc7..ff7bfa7 100644 --- a/VRChatApi/VRChatApi/Endpoints/RemoteConfig.cs +++ b/VRChatApi/VRChatApi/Endpoints/RemoteConfig.cs @@ -1,7 +1,5 @@ -using System; -using System.Net.Http; +using System.Net.Http; using System.Threading.Tasks; -using Newtonsoft.Json; using VRChatApi.Classes; using VRChatApi.Logging; @@ -14,18 +12,14 @@ public class RemoteConfig public async Task Get() { Logger.Trace(() => "Getting remote config"); + HttpResponseMessage response = await Global.HttpClient.GetAsync("config"); - ConfigResponse res = null; + ConfigResponse res = await Utils.ParseResponse(response); + + Global.ApiKey = res.clientApiKey; - if (response.IsSuccessStatusCode) - { - var json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - res = JsonConvert.DeserializeObject(json); - Global.ApiKey = res.clientApiKey; - Logger.Info(() => $"API key has been set to: {Global.ApiKey}"); - } + Logger.Info(() => $"API key has been set to: {res.clientApiKey}"); return res; } diff --git a/VRChatApi/VRChatApi/Endpoints/UserApi.cs b/VRChatApi/VRChatApi/Endpoints/UserApi.cs index 9dbb4cc..11c010f 100644 --- a/VRChatApi/VRChatApi/Endpoints/UserApi.cs +++ b/VRChatApi/VRChatApi/Endpoints/UserApi.cs @@ -8,115 +8,97 @@ using System.Threading.Tasks; using VRChatApi.Classes; using VRChatApi.Logging; + namespace VRChatApi.Endpoints { public class UserApi { private static readonly ILog Logger = LogProvider.GetCurrentClassLogger(); + public string Username { get; set; } public string Password { get; set; } + public UserApi(string username, string password) { Logger.Trace(() => $"Entering {nameof(UserApi)} constructor with username: {username}"); + Username = username; Password = password; } + public async Task Login() { Logger.Trace(() => "Getting current user details"); + HttpResponseMessage response = await Global.HttpClient.GetAsync($"auth/user?apiKey={Global.ApiKey}"); - UserResponse res = null; - if (response.IsSuccessStatusCode) - { - string json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - res = JsonConvert.DeserializeObject(json); - } - UserResponse result = new UserResponse(); - result.Raw = response; - if (res != null) result = res; - return result; + + return await Utils.ParseResponse(response); } + public async Task Register(string username, string password, string email, string birthday = null, string acceptedTOSVersion = null) { Logger.Debug(() => $"Registering new user with {nameof(username)} = {username}, {nameof(email)} = {email}, {nameof(birthday)} = {birthday}, {nameof(acceptedTOSVersion)} = {acceptedTOSVersion}"); - JObject json = new JObject(); - json["username"] = username; - json["password"] = password; - if (email != null) - json["email"] = email; - if (birthday != null ) - json["birthday"] = birthday; - if (acceptedTOSVersion != null) - json["acceptedTOSVersion"] = acceptedTOSVersion; + + JObject json = new JObject() + { + { "username", username }, + { "password", password } + }; + + json.AddIfNotNull("email", email); + json.AddIfNotNull("birthday", birthday); + json.AddIfNotNull("acceptedTOSVersion", acceptedTOSVersion); + Logger.Debug(() => $"Prepared JSON to post: {json}"); + StringContent content = new StringContent(json.ToString(), Encoding.UTF8); + content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + HttpResponseMessage response = await Global.HttpClient.PostAsync($"auth/register?apiKey={Global.ApiKey}", content); - UserResponse res = null; - if (response.IsSuccessStatusCode) - { - var receivedJson = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {receivedJson}"); - res = JsonConvert.DeserializeObject(receivedJson); - } - return res; + + return await Utils.ParseResponse(response); } + public async Task> Search(string pattern, int limit = 100, int offset = 0) { + Logger.Debug(() => $"Searching user info with pattern: {pattern}"); + HttpResponseMessage response = await Global.HttpClient.GetAsync($"users/?apiKey={Global.ApiKey}&n={limit}&offset={offset}&search={pattern}"); - List res = null; - if (response.IsSuccessStatusCode) - { - string json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - res = JsonConvert.DeserializeObject>(json); - } - return res; + + return await Utils.ParseResponse>(response); } + public async Task GetById(string userId) { Logger.Debug(() => $"Getting user info with ID: {userId}"); + HttpResponseMessage response = await Global.HttpClient.GetAsync($"users/{userId}?apiKey={Global.ApiKey}"); - UserBriefResponse res = null; - if (response.IsSuccessStatusCode) - { - string json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - res = JsonConvert.DeserializeObject(json); - } - return res; + + return await Utils.ParseResponse(response); } + public async Task UpdateInfo(string userId, string email = null, string birthday = null, string acceptedTOSVersion = null, List tags = null, string status = null, string statusDescription = null) { Logger.Debug(() => $"Updating user info for {nameof(userId)} = {userId} with {nameof(email)} = {email}, {nameof(birthday)} = {birthday}, {nameof(acceptedTOSVersion)} = {acceptedTOSVersion}, {nameof(tags)} = {tags}, {nameof(status)} = {status}, {nameof(statusDescription)} = {statusDescription}"); + JObject json = new JObject(); - if (email != null) - json["email"] = email; - if (birthday != null) - json["birthday"] = birthday; - if (acceptedTOSVersion != null) - json["acceptedTOSVersion"] = acceptedTOSVersion; - if (tags != null) - json["tags"] = JToken.FromObject(tags); - if (status != null) - json["status"] = status; - if (statusDescription != null) - json["statusDescription"] = statusDescription; + json.AddIfNotNull("email", email); + json.AddIfNotNull("birthday", birthday); + json.AddIfNotNull("acceptedTOSVersion", acceptedTOSVersion); + if (tags != null) json.Add("tags", JToken.FromObject(tags)); + json.AddIfNotNull("status", status); + json.AddIfNotNull("statusDescription", statusDescription); + Logger.Debug(() => $"Prepared JSON to put: {json}"); + StringContent content = new StringContent(json.ToString(), Encoding.UTF8); + content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + HttpResponseMessage response = await Global.HttpClient.PutAsync($"users/{userId}?apiKey={Global.ApiKey}", content); - UserResponse res = new UserResponse(); - res.Raw = response; - // res = await VRChatApi.ParseResponseAsync(response); - if (response.IsSuccessStatusCode) - { - var receivedJson = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {receivedJson}"); - res = JsonConvert.DeserializeObject(receivedJson); - } - return res; + + return await Utils.ParseResponse(response); } } -} \ No newline at end of file +} diff --git a/VRChatApi/VRChatApi/Endpoints/WorldAPI.cs b/VRChatApi/VRChatApi/Endpoints/WorldAPI.cs index 5de98cc..ccd059d 100644 --- a/VRChatApi/VRChatApi/Endpoints/WorldAPI.cs +++ b/VRChatApi/VRChatApi/Endpoints/WorldAPI.cs @@ -23,21 +23,14 @@ public async Task Get(string id) HttpResponseMessage response = await Global.HttpClient.GetAsync($"worlds/{id}?apiKey={Global.ApiKey}"); - WorldResponse res = null; + var res = await Utils.ParseResponse(response); - if (response.IsSuccessStatusCode) + // parse instances + res.instances = res._instances.Select(data => new WorldInstance() { - string json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - res = JsonConvert.DeserializeObject(json); - - // Parse instances. - res.instances = res._instances.Select(data => new WorldInstance() - { - id = (string)data[0], - occupants = (int)data[1] - }).ToList(); - } + id = (string)data[0], + occupants = (int)data[1] + }).ToList(); return res; } @@ -48,7 +41,9 @@ public async Task> Search(WorldGroups? endpoint = null, ReleaseStatus? releaseStatus = null, int offset = 0, int count = 20) { Logger.Debug(() => "Getting world list"); + var param = new StringBuilder(); + param.Append($"&n={count}"); param.Append($"&offset={offset}"); @@ -73,19 +68,37 @@ public async Task> Search(WorldGroups? endpoint = null, } if (user.HasValue) + { param.Append($"&user={user.Value.ToString().ToLowerInvariant()}"); + } + if (!string.IsNullOrEmpty(userId)) + { param.Append($"&userId={userId}"); + } + if (!string.IsNullOrEmpty(keyword)) + { param.Append($"&search={keyword}"); + } + if (!string.IsNullOrEmpty(tags)) + { param.Append($"&tag={tags}"); + } + if (!string.IsNullOrEmpty(excludeTags)) + { param.Append($"¬ag={excludeTags}"); + } + if (releaseStatus.HasValue) + { param.Append($"&releaseStatus={releaseStatus.Value.ToString().ToLowerInvariant()}"); + } string baseUrl = "worlds"; + if (endpoint.HasValue) { switch (endpoint.Value) @@ -104,38 +117,22 @@ public async Task> Search(WorldGroups? endpoint = null, HttpResponseMessage response = await Global.HttpClient.GetAsync($"{baseUrl}?apiKey={Global.ApiKey}{param.ToString()}"); - List res = null; - - if (response.IsSuccessStatusCode) - { - string json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - res = JsonConvert.DeserializeObject>(json); - } - - return res; + return await Utils.ParseResponse>(response); } public async Task GetMetadata(string id) { Logger.Debug(() => $"Getting world metadata with ID: {id}"); - HttpResponseMessage response = await Global.HttpClient.GetAsync($"worlds/{id}/metadata?apiKey={Global.ApiKey}"); - - WorldMetadataResponse res = null; - if (response.IsSuccessStatusCode) - { - string json = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {json}"); - res = JsonConvert.DeserializeObject(json); - } + HttpResponseMessage response = await Global.HttpClient.GetAsync($"worlds/{id}/metadata?apiKey={Global.ApiKey}"); - return res; + return await Utils.ParseResponse(response); } public async Task GetInstance(string worldId, string instanceId) { Logger.Debug(() => $"Getting world instance with world ID: {worldId} and instance ID {instanceId}"); + HttpResponseMessage response = await Global.HttpClient.GetAsync($"worlds/{worldId}/{instanceId}?apiKey={Global.ApiKey}"); WorldInstanceResponse res = null; @@ -157,10 +154,12 @@ public async Task GetInstance(string worldId, string inst users = (json["users"] is JArray) ? json["users"].Select(tk => tk.ToObject()).ToList() : null, hidden = (json["hidden"] == null || json["hidden"].Type == JTokenType.Null) ? null : json["hidden"].ToString(), - nonce = (json["nonce"] == null) ? null : json["nonce"].ToString(), + nonce = json["nonce"]?.ToString(), }; } + response.Dispose(); + return res; } } diff --git a/VRChatApi/VRChatApi/Utils.cs b/VRChatApi/VRChatApi/Utils.cs index 284b6df..50fa39d 100644 --- a/VRChatApi/VRChatApi/Utils.cs +++ b/VRChatApi/VRChatApi/Utils.cs @@ -1,12 +1,79 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Net.Http; +using System.Runtime.CompilerServices; using System.Threading.Tasks; +using VRChatApi.Logging; +using VRChatApi.Classes; +using System.Reflection; +using System.ComponentModel; namespace VRChatApi { - class Utils + static class Utils { + public static void AddIfNotNull(this JObject jObject, string key, string value) + { + if (!string.IsNullOrEmpty(value)) + { + jObject[key] = value; + } + } + + public static void AddIfNotNull(this JObject jObject, string key, JToken value) + { + if (value.HasValues) + { + jObject[key] = value; + } + } + + private static readonly ILog Logger = LogProvider.GetCurrentClassLogger(); + + public static async Task ParseResponse(HttpResponseMessage responseMessage) where T : class + { + T res = null; + /*switch (T.GetType()) + { + case typeof(UserBriefResponse): + UserBriefResponse res = null; + break; + default: + break; + } + res.Raw = responseMessage;*/ + if (responseMessage.IsSuccessStatusCode) + { + var receivedJson = await responseMessage.Content.ReadAsStringAsync(); + + Logger.Debug(() => $"JSON received: {receivedJson}"); + + res = JsonConvert.DeserializeObject(receivedJson); + + } + + responseMessage.Dispose(); + + return res; + } + } + static class Extensions + { + public static string GetDescription(this Enum value) + { + Type type = value.GetType(); + string name = Enum.GetName(type, value); + if (name != null) { + FieldInfo field = type.GetField(name); + if (field != null) { + DescriptionAttribute attr = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute; + if (attr != null) { + return attr.Description; + } + } + } + return null; + } } } diff --git a/VRChatApi/VRChatApi/VRChatApi.cs b/VRChatApi/VRChatApi/VRChatApi.cs index 2029244..d6b8283 100644 --- a/VRChatApi/VRChatApi/VRChatApi.cs +++ b/VRChatApi/VRChatApi/VRChatApi.cs @@ -16,6 +16,7 @@ public class VRChatApi public WorldApi WorldApi { get; set; } public ModerationsApi ModerationsApi { get; set; } public AvatarApi AvatarApi { get; set; } + public FavouriteApi FavouriteApi { get; set; } public NotificationsAPI NotificationsAPI { get; set; } public VRChatApi(string username, string password) @@ -30,6 +31,7 @@ public VRChatApi(string username, string password) WorldApi = new WorldApi(); ModerationsApi = new ModerationsApi(); AvatarApi = new AvatarApi(); + FavouriteApi = new FavouriteApi(); NotificationsAPI = new NotificationsAPI(); // initialize http client @@ -45,26 +47,16 @@ public VRChatApi(string username, string password) string authEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{UserApi.Username}:{UserApi.Password}")); var header = Global.HttpClient.DefaultRequestHeaders; + if (header.Contains("Authorization")) { Logger.Debug(() => "Removing existing Authorization header"); header.Remove("Authorization"); } + header.Add("Authorization", $"Basic {authEncoded}"); + Logger.Trace(() => $"Added new Authorization header"); } - - /*public static async System.Threading.Tasks.Task ParseResponseAsync(HttpResponseMessage response, Type Class = null) - { - Object theObject = Activator.CreateInstance(Class); - var test = new Class(); - if (response.IsSuccessStatusCode) - { - var receivedJson = await response.Content.ReadAsStringAsync(); - Logger.Debug(() => $"JSON received: {receivedJson}"); - res = JsonConvert.DeserializeObject(receivedJson); - } - return theObject; - }*/ } } diff --git a/VRChatApi/VRChatApi/VRChatApi.csproj b/VRChatApi/VRChatApi/VRChatApi.csproj index bdc0864..4c4c658 100644 --- a/VRChatApi/VRChatApi/VRChatApi.csproj +++ b/VRChatApi/VRChatApi/VRChatApi.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -15,6 +15,7 @@ + From c8b36088701dc901f92e492818e17d165a0ec944 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Sat, 10 Aug 2019 05:05:50 +0200 Subject: [PATCH 14/20] update repo --- VRChatApi/VRChatApi/Classes/NotificationResponse.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/VRChatApi/VRChatApi/Classes/NotificationResponse.cs b/VRChatApi/VRChatApi/Classes/NotificationResponse.cs index ab5ca1f..68014a4 100644 --- a/VRChatApi/VRChatApi/Classes/NotificationResponse.cs +++ b/VRChatApi/VRChatApi/Classes/NotificationResponse.cs @@ -21,7 +21,6 @@ public class NotificationResponse : Response public string SenderUsername { get; set; } public string ReceiverUserId { get; set; } public string Message { get; set; } - public NotificationDetails details { get; set; } [JsonProperty(PropertyName = "created_at")] public string Created { get; set; } public DateTime CreatedAt { get { return Convert.ToDateTime(Created); } } From 166b8f033917822e52a3648cd3a603ea2650025f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 11:27:34 +0000 Subject: [PATCH 15/20] Add renovate.json --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..39a2b6e --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ] +} From 0efe18a400e94d7e1d7f2cdc18b638fca5a55cb7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 07:48:23 +0000 Subject: [PATCH 16/20] Update dependency FluentAssertions to v5.10.3 --- VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj b/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj index 81e3ad1..56e5917 100644 --- a/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj +++ b/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj @@ -11,7 +11,7 @@ - + From 9f479957737d22e9544fb286cb54d4675b439d44 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 08:30:00 +0000 Subject: [PATCH 17/20] Update dependency Microsoft.CSharp to v4.7.0 --- VRChatApi/VRChatApi/VRChatApi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VRChatApi/VRChatApi/VRChatApi.csproj b/VRChatApi/VRChatApi/VRChatApi.csproj index 4c4c658..bd2532b 100644 --- a/VRChatApi/VRChatApi/VRChatApi.csproj +++ b/VRChatApi/VRChatApi/VRChatApi.csproj @@ -13,7 +13,7 @@ all runtime; build; native; contentfiles; analyzers - + From 7b757dcda47c838ac04e636affb8f28671019fcb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 08:30:05 +0000 Subject: [PATCH 18/20] Update dependency Microsoft.NET.Test.Sdk to v15.9.2 --- VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj b/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj index 56e5917..cf6a001 100644 --- a/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj +++ b/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj @@ -12,7 +12,7 @@ - + From 73a4fa1184ff60c8eba41207e7373b239aff9479 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 09:08:42 +0000 Subject: [PATCH 19/20] Update dependency Moq to v4.20.69 --- VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj b/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj index cf6a001..252cae9 100644 --- a/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj +++ b/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj @@ -13,7 +13,7 @@ - + all From 830039b631a6c61eb27f380ce6f794ac73b372c8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 09:44:00 +0000 Subject: [PATCH 20/20] Update xunit-dotnet monorepo --- VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj b/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj index 252cae9..153a2b4 100644 --- a/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj +++ b/VRChatApi/VRChatApi.Tests/VRChatApi.Tests.csproj @@ -14,8 +14,8 @@ - - + + all runtime; build; native; contentfiles; analyzers