// TODO Blocking Time default public void requestStrategy(IGoedleDownloadBuffer goedleDownloadBuffer) { GoedleUtils gu = new GoedleUtils(); string url = gu.getStrategyUrl(_app_key); _gio_http_client.requestStrategy(url, this, _gwr, goedleDownloadBuffer, _staging); }
public void SetUp() { _app_key = "test_app_key"; _user_id = "u1"; _app_version = "v_test"; _ts = 0; _app_name = "test_app"; _timezone = 360000; _event_name = "test_event"; _event_id = null; _event_value = null; _ga_active = false; _anonymous_id = null; _trait_key = null; _trait_value = null; _api_key = "test_api_key"; _GA_TRACKIND_ID = null; _GA_CD_1 = 0; _GA_CD_2 = 0; _GA_CD_EVENT = "group"; _url = "test_url"; _staging = false; _gio_http_client = (new GameObject("GoedleHTTPClient")).AddComponent <GoedleHttpClient>(); _gdb = Substitute.For <IGoedleDownloadBuffer>(); _guh = Substitute.For <IGoedleUploadHandler>(); _gw = Substitute.For <IGoedleWebRequest>(); }
public void SetUp() { _app_key = "test_app_key"; _user_id = "u1"; _app_version = "v_test"; _ts = 0; _app_name = "test_app"; _timezone = 360000; _event_name = "test_event"; _event_id = null; _event_value = null; _ga_active = false; _anonymous_id = null; _trait_key = null; _trait_value = null; _api_key = "test_api_key"; _GA_TRACKIND_ID = null; _GA_CD_1 = 0; _GA_CD_2 = 0; _GA_CD_EVENT = "group"; _url = "test_url"; _staging = false; _content = true; _gw = Substitute.For <IGoedleWebRequest>(); _guh = Substitute.For <IGoedleUploadHandler>(); _gdb = Substitute.For <IGoedleDownloadBuffer>(); _gio_object = new GoedleAnalytics( _api_key, _app_key, _user_id, _app_version, _GA_TRACKIND_ID, _app_name, _GA_CD_1, _GA_CD_2, _GA_CD_EVENT, _gio_http_client, _gw, _guh, _staging, _content); }
/* * Returns an JSONNode object this can be accessed via: * CoroutineWithData cd = new CoroutineWithData(this, LoadSomeStuff( ) ); * yield return cd.coroutine; * Debug.Log("result is " + cd.result); // 'JSONNode' * CoroutineWithData is in GoedleUtils */ public IEnumerator getJSONResponse(string url, GoedleAnalytics ga, IGoedleWebRequest gwr, IGoedleDownloadBuffer gdb, bool staging) { if (staging) { Debug.Log("Staging is on your get request would look like this:\n" + url); } else { gwr.unityWebRequest = new UnityWebRequest(); using (gwr.unityWebRequest) { gwr.method = "GET"; gwr.url = url; gwr.downloadHandler = gdb.downloadHandlerBuffer; yield return(gwr.SendWebRequest()); JSONNode strategy_json = null; if (gwr.isNetworkError || gwr.isHttpError) { Debug.Log("{\"error\": { \"isHttpError\": \"" + gwr.isHttpError + "\", \"isNetworkError\": \"" + gwr.isNetworkError + "\" } }"); strategy_json = null; } else { // Show results as text try { Debug.Log("The following strategy was received: " + gdb.text); strategy_json = JSON.Parse(gdb.text); } catch (Exception e) { Debug.Log("{\"error\": \" " + e.Message + " \"}"); strategy_json = null; } // Or retrieve results as binary data //byte[] results = client.downloadHandler.data; } ga.strategy = strategy_json; yield break; } } }
public void requestStrategy(string url, GoedleAnalytics ga, IGoedleWebRequest gwr, IGoedleDownloadBuffer gdb, bool staging) { StartCoroutine(getJSONResponse(url, ga, gwr, gdb, staging)); }