public async void GetKeys(bool useUsername, string pattern) { if (useUsername) { if (!LoggedIn) { throw new Exception("User not logged in!"); } else { var url = new APIURL("/data-store/get-keys/") { { "game_id", GameID }, { "username", Username }, { "user_token", Token }, { "pattern", pattern } }; await Initialize(url.GetURL, RequestMethod.GET); } } else { var url = new APIURL("/data-store/get-keys/") { { "game_id", GameID }, { "pattern", pattern } }; await Initialize(url.GetURL, RequestMethod.GET); } }
public async void RemoveKey(string key, bool useUsername) { if (useUsername) { if (!LoggedIn) { throw new Exception("User Not logged in!"); } else { var url = new APIURL("/data-store/remove/") { { "game_id", GameID }, { "username", Username }, { "user_token", Token }, { "key", key } }; await Initialize(url.GetURL, RequestMethod.POST); } } else { var url = new APIURL("/data-store/remove/") { { "game_id", GameID }, { "key", key } }; await Initialize(url.GetURL, RequestMethod.POST); } }
public async void SetStorageData(string key, string data, bool useUsername) { if (useUsername) { if (!LoggedIn) { var up = new Exception("User not logged in!"); //Happens when a user tries to send an API call but is not logged in. throw up; } else { var url = new APIURL("/data-store/set/") { { "game_id", GameID }, { "username", Username }, { "user_token", Token }, { "key", key } }; await Initialize(url.GetURL, RequestMethod.POST, data); } } else { var url = new APIURL("/data-store/set/") { { "game_id", GameID }, { "key", key } }; await Initialize(url.GetURL, RequestMethod.POST, data); } }
public async void FetchUserdataByID(string user_id) { var url = new APIURL("/users/") { { "game_id", GameID }, { "user_id", user_id } }; await Initialize(url.GetURL, RequestMethod.GET); }
public async void FetchFriendList(string user_id) { var url = new APIURL("/friends/") { { "game_id", GameID }, { "user_id", user_id } }; await Initialize(url.GetURL, RequestMethod.GET); }
public async void FetchAllTrophies() { var url = new APIURL("/trophies/") { { "game_id", GameID }, { "username", Username }, { "user_token", Token } }; await Initialize(url.GetURL, RequestMethod.GET); }
public async void FetchUserRank(string table_id, int sort) { var url = new APIURL("/scores/get-rank/") { { "game_id", GameID }, { "sort", sort.ToString(NumberFormatInfo.InvariantInfo) }, { "table_id", table_id } }; await Initialize(url.GetURL, RequestMethod.GET); }
public async void FetchReceivedFriendRequests() { var url = new APIURL("/friends/received-requests/") { { "game_id", GameID }, { "username", Username }, { "user_token", Token } }; await Initialize(url.GetURL, RequestMethod.GET); }
public async void FetchTable(int score_count, string table_id) { var url = new APIURL("/scores/") { { "game_id", GameID }, { "limit", score_count.ToString(NumberFormatInfo.InvariantInfo) }, { "table_id", table_id } }; await Initialize(url.GetURL, RequestMethod.GET); }
public async void CloseSession() { var url = new APIURL("/sessions/close/") { { "game_id", GameID }, { "username", Username }, { "user_token", Token } }; await Initialize(url.GetURL, RequestMethod.GET); }
public async void RemoveTrophyAchieved(int trophy_id) { var url = new APIURL("/trophies/remove-achieved/") { { "game_id", GameID }, { "username", Username }, { "user_token", Token }, { "trophy_id", trophy_id.ToString(NumberFormatInfo.InvariantInfo) } }; await Initialize(url.GetURL, RequestMethod.POST); }
public override int GetHashCode() { return (AbsoluteMinimumPartSize.GetHashCode() ^ AccountID.GetHashCode() ^ APIURL.GetHashCode() ^ ApplicationKey.GetHashCode() ^ AuthorizationToken.GetHashCode() ^ DownloadURL.GetHashCode() ^ RecommendedPartSize.GetHashCode() ^ SessionExpirationDate.GetHashCode()); }
public async void DeclineFriendRequest(string targetUserID) { var url = new APIURL("/friends/decline-request/") { { "game_id", GameID }, { "username", Username }, { "user_token", Token }, { "target_user_id", targetUserID } }; await Initialize(url.GetURL, RequestMethod.POST); }
public async void AddScore(string score, int sort, string table_id) { var url = new APIURL("/scores/add/") { { "game_id", GameID }, { "username", Username }, { "user_token", Token }, { "score", score }, { "sort", sort.ToString(NumberFormatInfo.InvariantInfo) }, { "table_id", table_id } }; await Initialize(url.GetURL, RequestMethod.POST); }
public async void VerifyUser(string newUsername, string newToken) { API.Username = newUsername; API.Token = newToken; Username = newUsername; Token = newToken; var url = new APIURL("/users/auth/") { { "game_id", GameID }, { "username", Username }, { "user_token", Token } }; await Initialize(url.GetURL, RequestMethod.GET); }
public bool Equals(BackblazeB2AuthorizationSession other) { if (EqualsPreamble(other) == false) { return(false); } return (AbsoluteMinimumPartSize == other.AbsoluteMinimumPartSize && AccountID.Equals(other.AccountID, StringComparison.Ordinal) && APIURL.Equals(other.APIURL, StringComparison.Ordinal) && ApplicationKey.Equals(other.ApplicationKey, StringComparison.Ordinal) && AuthorizationToken.Equals(other.AuthorizationToken, StringComparison.Ordinal) && DownloadURL.Equals(other.DownloadURL, StringComparison.Ordinal) && RecommendedPartSize == other.RecommendedPartSize && SessionExpirationDate.Equals(other.SessionExpirationDate)); }
protected string ConstructAPIURL(string url) { if (!url.StartsWith("http")) { if (url.StartsWith("/") && APIURL.EndsWith("/")) { url = url.Substring(1); } if (!url.StartsWith("/") && !APIURL.EndsWith("/")) { url = "/" + url; } if (!url.StartsWith("http")) { url = APIURL + url; } } return(url); }
public async void UpdateStorageData(string key, string value, string operation, bool useUsername) { if (useUsername) { if (!LoggedIn) { var up = new Exception("User not logged in!"); //Happens when a user tries to send an API call but is not logged in. throw up; } else { var url = new APIURL("/data-store/update/") { { "game_id", GameID }, { "username", Username }, { "user_token", Token }, { "key", key }, { "operation", operation }, { "value", value } }; await Initialize(url.GetURL, RequestMethod.GET); } } else { var url = new APIURL("/data-store/update/") { { "game_id", GameID }, { "key", key }, { "operation", operation }, { "value", value } }; await Initialize(url.GetURL, RequestMethod.GET); } }