public void RequestBattle(string tileId, APIResponseHandler handler) { var path = string.Format("/api/battles"); Post(path, new Dictionary <string, string>() { { "tile_id", tileId } }, handler); }
protected IEnumerator GetRequest(string path, APIResponseHandler handler) { var url = string.Format("{0}{1}", RootUrl, path); Debug.Log(string.Format("Headers: client={0}, access-token={1}, uid={2}", PlayerPrefs.GetString("client"), PlayerPrefs.GetString("access-token"), PlayerPrefs.GetString("uid"))); Debug.Log("GET " + url); var www = new WWW(url, null, Headers()); yield return(www); handler(www); }
public void LogIn(string email, string password, APIResponseHandler handler) { var path = "/auth/sign_in"; var body = new Dictionary <string, string>() { { "email", email }, { "password", password } }; Debug.Log("Posting email: " + email + " and password: " + password); Post(path, body, handler); }
public void SignUp(string email, string handle, string password, APIResponseHandler handler) { var path = "/auth.json"; var body = new Dictionary <string, string>() { { "nickname", handle }, { "email", email }, { "password", password }, { "password_confirmation", password } }; Debug.Log("Posting email: " + email + " and password: " + password); Post(path, body, handler); }
public void TestUser(APIResponseHandler successHandler, APIResponseHandler errorHandler) { var path = string.Format("/api/user"); Get(path, (response) => { var status = response.responseHeaders["STATUS"]; if (status.Contains("200")) { WriteUserInfo(JSON.Parse(response.text)); successHandler.Invoke(response); } else { errorHandler.Invoke(response); } }); }
protected IEnumerator PostRequest(string path, Dictionary <string, string> body, APIResponseHandler handler) { var url = string.Format("{0}{1}", RootUrl, path); Debug.Log("POST " + url); var form = new WWWForm(); foreach (KeyValuePair <string, string> kv in body) { form.AddField(kv.Key, kv.Value); } var www = new WWW(url, form.data, Headers()); yield return(www); handler(www); }
public void RequestTile(string id, APIResponseHandler handler) { var path = string.Format("/api/tiles/{0}", id); Get(path, handler); }
public void TestAuth(APIResponseHandler handler) { var path = string.Format("/auth/validate_token?uid={0}&client={1}&access-token={2}", uid, client, accessToken); Get(path, handler); }
protected void Post(string path, Dictionary <string, string> body, APIResponseHandler handler) { StartCoroutine(PostRequest(path, body, handler)); }
protected void Get(string path, APIResponseHandler handler) { StartCoroutine(GetRequest(path, handler)); }