diff --git a/ShiftOS_TheReturn/UniteClient.cs b/ShiftOS_TheReturn/UniteClient.cs index 8d6a58d..d8e34b7 100644 --- a/ShiftOS_TheReturn/UniteClient.cs +++ b/ShiftOS_TheReturn/UniteClient.cs @@ -11,7 +11,14 @@ namespace ShiftOS.Unite { public class UniteClient { + /// + /// Gets a string represents the user token for this Unite Client. + /// public string Token { get; private set; } + + /// + /// Gets the base URL used in all API calls. Retrieved from the user's servers.json file. + /// public string BaseURL { get @@ -20,16 +27,30 @@ namespace ShiftOS.Unite } } + /// + /// Get the display name of a user. + /// + /// The user ID to look at. + /// public string GetDisplayNameId(string id) { return MakeCall("/API/GetDisplayName/" + id); } + /// + /// Get the Pong highscore stats for all users. + /// + /// public PongHighscoreModel GetPongHighscores() { return JsonConvert.DeserializeObject(MakeCall("/API/GetPongHighscores")); } + /// + /// Create a new instance of the object. + /// + /// Unused. + /// The user API token to use for this client (see http://getshiftos.ml/Manage and click "API" to see your tokens) public UniteClient(string baseurl, string usertoken) { //Handled by the servers.json file @@ -37,6 +58,11 @@ namespace ShiftOS.Unite Token = usertoken; } + /// + /// Make a call to the Unite API using the current user token and base URL. + /// + /// The path, relative to the base URL, to call. + /// The server's response. internal string MakeCall(string url) { var webrequest = WebRequest.Create(BaseURL + url); @@ -53,83 +79,158 @@ namespace ShiftOS.Unite } } + /// + /// Get the Pong codepoint highscore for the current user. + /// + /// The amount of Codepoints returned by the server public int GetPongCP() { return Convert.ToInt32(MakeCall("/API/GetPongCP")); } + /// + /// Get the pong highest level score for this user + /// + /// The highest level the user has reached. public int GetPongLevel() { return Convert.ToInt32(MakeCall("/API/GetPongLevel")); } + /// + /// Set the user's highest level record for Pong. + /// + /// The level to set the record to. public void SetPongLevel(int value) { MakeCall("/API/SetPongLevel/" + value.ToString()); } + /// + /// Set the pong Codepoints record for the user + /// + /// The amount of Codepoints to set the record to public void SetPongCP(int value) { MakeCall("/API/SetPongCP/" + value.ToString()); } + /// + /// Get the user's email address. + /// + /// The user's email address. public string GetEmail() { return MakeCall("/API/GetEmail"); } + /// + /// Get the user's system name. + /// + /// The user's system name. public string GetSysName() { return MakeCall("/API/GetSysName"); } + /// + /// Set the user's system name. + /// + /// The system name to set the record to. public void SetSysName(string value) { MakeCall("/API/SetSysName/" + value); } + /// + /// Get the user's display name. + /// + /// The user's display name. public string GetDisplayName() { return MakeCall("/API/GetDisplayName"); } + /// + /// Set the user's display name. + /// + /// The display name to set the user's account to. public void SetDisplayName(string value) { MakeCall("/API/SetDisplayName/" + value.ToString()); } + /// + /// Get the user's full name if they have set it in their profile. + /// + /// Empty string if the user hasn't set their fullname, else, a string representing their fullname. public string GetFullName() { return MakeCall("/API/GetFullName"); } + /// + /// Set the user's fullname. + /// + /// The new fullname. public void SetFullName(string value) { MakeCall("/API/SetFullName/" + value.ToString()); } - + /// + /// Get the user's codepoints. + /// + /// The amount of codepoints stored on the server for this user. public long GetCodepoints() { return Convert.ToInt64(MakeCall("/API/GetCodepoints")); } + /// + /// Set the user's codepoints. + /// + /// The amount of codepoints to set the user's codepoints value to. public void SetCodepoints(long value) { MakeCall("/API/SetCodepoints/" + value.ToString()); } } + /// + /// API data model for Unite pong highscores. + /// public class PongHighscoreModel { + /// + /// Amount of pages in this list. + /// public int Pages { get; set; } + + /// + /// An array representing the highscores found on the server. + /// public PongHighscore[] Highscores { get; set; } } + /// + /// API data model for a single Pong highscore. + /// public class PongHighscore { + /// + /// The user ID linked to this highscore. + /// public string UserId { get; set; } + + /// + /// The highscore's level record. + /// public int Level { get; set; } + + /// + /// The highscore's codepoint cashout record. + /// public long CodepointsCashout { get; set; } } }