public static void LoginUserWithGameCenterId(string id, Action <bool> callback) { string auth = System.Convert.ToBase64String(Encoding.UTF8.GetBytes("gamecenter|" + id)); Dictionary <string, string> body = new Dictionary <string, string>(); body.Add("Authorization", auth); Gamedonia.RunCoroutine( GamedoniaRequest.post("/account/login", JsonMapper.ToJson(body), auth, null, null, delegate(bool success, object data) { if (success) { sessionToken = JsonMapper.ToObject <GDSessionToken>((string)data); PlayerPrefs.SetString("gd_session_token", sessionToken.session_token); RegisterDeviceAfterLogin(callback); } else { if (callback != null) { callback(success); } } } ) ); }
public static void Run(string script, Dictionary <string, object> parameters, Action <bool, object> callback = null) { string json = "{}"; if (parameters != null) { json = JsonMapper.ToJson(parameters); } Gamedonia.RunCoroutine( GamedoniaRequest.post("/run/" + script, json, null, GamedoniaUsers.GetSessionToken(), null, delegate(bool success, object data) { if (callback != null) { if (success) { string strData = data as String; if (strData.Length > 0) { callback(success, Json.Deserialize(strData)); } else { callback(success, null); } } else { callback(success, null); } } } ) ); }
public static void Count(string collection, string query, Action <bool, int> callback = null) { query = Uri.EscapeDataString(query); string url = "/data/" + collection + "/count?query=" + query; Gamedonia.RunCoroutine( GamedoniaRequest.get(url, GamedoniaUsers.GetSessionToken(), delegate(bool success, object data) { if (callback != null) { if (success) { IDictionary response = Json.Deserialize((string)data) as IDictionary; int count = int.Parse(response["count"].ToString()); callback(success, count); } else { callback(success, -1); } } } ) ); }
public static void Delete(string collection, string entityId, Action <bool> callback = null) { Gamedonia.RunCoroutine( GamedoniaRequest.delete("/data/" + collection + "/delete/" + entityId, GamedoniaUsers.GetSessionToken(), delegate(bool success, object data) { callback(success); } ) ); }
private static void Profile(GDDeviceProfile device, Action <bool> callback) { Gamedonia.RunCoroutine( ProfilePushNotification(device, delegate(bool success) { callback(success); } ) ); }
public static void CreateUser(GDUser user, Action <bool> callback) { string json = JsonMapper.ToJson(user); Gamedonia.RunCoroutine( GamedoniaRequest.post("/account/create", json, delegate(bool success, object data) { if (callback != null) { callback(success); } } ) ); }
public static void Register(GDDeviceProfile device, Action <bool> callback = null) { string json = JsonMapper.ToJson(device); Gamedonia.RunCoroutine( GamedoniaRequest.post("/device/register", json, delegate(bool success, object data) { if (callback != null) { callback(success); } } ) ); }
public static void VerifyPurchase(Dictionary <string, object> parameters, Action <bool> callback = null) { string json = JsonMapper.ToJson(parameters); Gamedonia.RunCoroutine( GamedoniaRequest.post("/purchase/verify", json, null, GamedoniaUsers.GetSessionToken(), null, delegate(bool success, object data) { if (callback != null) { callback(success); } } ) ); }
public static void ResetPassword(string email, Action <bool> callback) { Dictionary <string, string> body = new Dictionary <string, string>(); body.Add("email", email); Gamedonia.RunCoroutine( GamedoniaRequest.post("/account/password/reset", JsonMapper.ToJson(body), null, null, null, delegate(bool success, object data) { if (callback != null) { callback(success); } } ) ); }
public static void ChangePassword(string email, string currentPassword, string newPassword, Action <bool> callback) { string auth = System.Convert.ToBase64String(Encoding.UTF8.GetBytes("email|" + email + "|" + currentPassword)); Dictionary <string, string> body = new Dictionary <string, string>(); body.Add("password", newPassword); Gamedonia.RunCoroutine( GamedoniaRequest.post("/account/password/change", JsonMapper.ToJson(body), auth, null, null, delegate(bool success, object data) { if (callback != null) { callback(success); } } ) ); }
public static void LinkUser(Credentials credentials, Action <bool, GDUserProfile> callback) { Gamedonia.RunCoroutine( GamedoniaRequest.post("/account/link", JsonMapper.ToJson(credentials), null, sessionToken.session_token, null, delegate(bool success, object data) { if (success) { me = JsonMapper.ToObject <GDUserProfile>((string)data); } if (callback != null) { callback(success, me); } } ) ); }
public static void GetMe(Action <bool, GDUserProfile> callback) { Gamedonia.RunCoroutine( GamedoniaRequest.get("/account/me", sessionToken.session_token, delegate(bool success, object data) { if (success) { me = JsonMapper.ToObject <GDUserProfile>((string)data); } if (callback != null) { callback(success, me); } } ) ); }
public static void LogoutUser(Action <bool> callback) { Dictionary <string, string> body = new Dictionary <string, string>(); body.Add(GamedoniaRequest.GD_SESSION_TOKEN, sessionToken.session_token); Gamedonia.RunCoroutine( GamedoniaRequest.post("/account/logout", JsonMapper.ToJson(body), null, sessionToken.session_token, null, delegate(bool success, object data) { if (callback != null) { callback(success); } } ) ); }
public static void RestorePassword(string restoreToken, string newPassword, Action <bool> callback) { Dictionary <string, string> body = new Dictionary <string, string>(); body.Add("password", newPassword); Gamedonia.RunCoroutine( GamedoniaRequest.post("/account/password/restore/" + restoreToken, JsonMapper.ToJson(body), null, sessionToken.session_token, null, delegate(bool success, object data) { if (callback != null) { callback(success); } } ) ); }
public static void Update(string collection, Dictionary <string, object> entity, Action <bool, IDictionary> callback = null, bool overwrite = false) { string json = JsonMapper.ToJson(entity); if (!overwrite) { Gamedonia.RunCoroutine( GamedoniaRequest.post("/data/" + collection + "/update", json, null, GamedoniaUsers.GetSessionToken(), null, delegate(bool success, object data) { if (callback != null) { if (success) { callback(success, Json.Deserialize((string)data) as IDictionary); } else { callback(success, null); } } } ) ); } else { Gamedonia.RunCoroutine( GamedoniaRequest.put("/data/" + collection + "/update", json, null, GamedoniaUsers.GetSessionToken(), null, delegate(bool success, object data) { if (callback != null) { if (success) { callback(success, Json.Deserialize((string)data) as IDictionary); } else { callback(success, null); } } } ) ); } }
public static void Search(string collection, string query, int limit = 0, string sort = null, int skip = 0, Action <bool, IList> callback = null) { query = Uri.EscapeDataString(query); string url = "/data/" + collection + "/search?query=" + query; if (limit > 0) { url += "&limit=" + limit; } if (sort != null) { url += "&sort=" + sort; } if (skip > 0) { url += "&skip=" + skip; } Gamedonia.RunCoroutine( GamedoniaRequest.get(url, GamedoniaUsers.GetSessionToken(), delegate(bool success, object data) { if (callback != null) { if (success) { if ((data == null) || (data.Equals("[]"))) { callback(success, null); } else { callback(success, Json.Deserialize((string)data) as IList); } } else { callback(success, null); } } } ) ); }
public static void Search(string query, int limit = 0, string sort = null, int skip = 0, Action <bool, IList> callback = null) { string url = "/account/search?query=" + query; if (limit > 0) { url += "&limit=" + limit; } if (sort != null) { url += "&sort=" + sort; } if (skip > 0) { url += "&skip=" + skip; } Gamedonia.RunCoroutine( GamedoniaRequest.get(url, sessionToken.session_token, delegate(bool success, object data) { if (callback != null) { if (success) { if ((data == null) || (data.Equals("[]"))) { callback(success, null); } else { callback(success, Json.Deserialize((string)data) as IList); } } else { callback(success, null); } } } ) ); }
public static void Get(string collection, string entityId, Action <bool, IDictionary> callback = null) { Gamedonia.RunCoroutine( GamedoniaRequest.get("/data/" + collection + "/get/" + entityId, GamedoniaUsers.GetSessionToken(), delegate(bool success, object data) { if (callback != null) { if (success) { callback(success, Json.Deserialize((string)data) as IDictionary); } else { callback(success, null); } } } ) ); }
private void RequestAndAddDownload(string fileId) { string url = "/file/get/url/" + fileId; Gamedonia.RunCoroutine( GamedoniaRequest.get(url, GamedoniaUsers.GetSessionToken(), delegate(bool success, object data) { if (success) { //Debug.Log("Before Internal Download URL"); IDictionary dataDownload = Json.Deserialize((string)data) as IDictionary; InternalAddDownloadURL(dataDownload["downloadUrl"] as string, fileId); } else { InternalAddDownloadURL(fileId, fileId); } } ) ); }
public static void Delete(string collection, List <string> entities, bool all, Action <bool, int> callback = null) { if (all) { Gamedonia.RunCoroutine( GamedoniaRequest.delete("/data/" + collection + "/delete?all=true", GamedoniaUsers.GetSessionToken(), delegate(bool success, object data) { IDictionary response = Json.Deserialize((string)data) as IDictionary; if (success) { callback(success, int.Parse(response["deleted"].ToString())); } else { callback(success, 0); } } ) ); } else { Gamedonia.RunCoroutine( GamedoniaRequest.delete("/data/" + collection + "/delete?keys=" + String.Join(",", entities.ToArray()), GamedoniaUsers.GetSessionToken(), delegate(bool success, object data) { IDictionary response = Json.Deserialize((string)data) as IDictionary; if (success) { callback(success, int.Parse(response["deleted"].ToString())); } else { callback(success, 0); } } ) ); } }
public static void GetUser(string userId, Action <bool, GDUserProfile> callback) { Dictionary <string, string> body = new Dictionary <string, string>(); body.Add("_id", userId); Gamedonia.RunCoroutine( GamedoniaRequest.post("/account/retrieve", JsonMapper.ToJson(body), null, sessionToken.session_token, null, delegate(bool success, object data) { GDUserProfile user = null; if (success) { user = JsonMapper.ToObject <GDUserProfile>((string)data); } if (callback != null) { callback(success, user); } } ) ); }
public static void LoginUserWithSessionToken(Action <bool> callback) { string session_token = PlayerPrefs.GetString("gd_session_token"); if (session_token != null && session_token.Length > 0) { string auth = System.Convert.ToBase64String(Encoding.UTF8.GetBytes("session_token|" + session_token)); Dictionary <string, string> body = new Dictionary <string, string> (); body.Add(GamedoniaRequest.GD_AUTH, auth); Gamedonia.RunCoroutine( GamedoniaRequest.post("/account/login", JsonMapper.ToJson(body), auth, null, null, delegate(bool success, object data) { if (success) { sessionToken = JsonMapper.ToObject <GDSessionToken> ((string)data); RegisterDeviceAfterLogin(callback); } else { if (callback != null) { callback(success); } } } ) ); } else { Debug.LogWarning("No sessionToken stored in PlayerPrefs"); if (callback != null) { callback(false); } } }
public static void Count(string query, Action <bool, int> callback = null) { string url = "/account/count?query=" + query; Gamedonia.RunCoroutine( GamedoniaRequest.get(url, sessionToken.session_token, delegate(bool success, object data) { if (callback != null) { if (success) { IDictionary response = Json.Deserialize((string)data) as IDictionary; int count = int.Parse(response["count"].ToString()); callback(success, count); } else { callback(success, -1); } } }) ); }
public static void UpdateUser(Dictionary <string, object> profile, Action <bool> callback = null, bool overwrite = false) { if (!overwrite) { Gamedonia.RunCoroutine( GamedoniaRequest.post("/account/update", JsonMapper.ToJson(profile), null, sessionToken.session_token, null, delegate(bool success, object data) { if (success) { me = JsonMapper.ToObject <GDUserProfile>((string)data); } if (callback != null) { callback(success); } } ) ); } else { Gamedonia.RunCoroutine( GamedoniaRequest.put("/account/update", JsonMapper.ToJson(profile), null, sessionToken.session_token, null, delegate(bool success, object data) { if (success) { me = JsonMapper.ToObject <GDUserProfile>((string)data); } if (callback != null) { callback(success); } } ) ); } }
private void GetFileConentLength(string tempFilename, string url, Action <long> callback) { Gamedonia.RunCoroutine(InternalGetFileConentLength(tempFilename, url, callback)); }
private void DownloadFile(string tempFilename, string url, long downloadedBytes) { Gamedonia.RunCoroutine(InternalDownloadFile(tempFilename, url, downloadedBytes)); }