Exemplo n.º 1
0
        public IEnumerator postJSONRequest(string url, string authentification, IGoedleWebRequest gwr, IGoedleUploadHandler guh, bool staging)
        {
            if (staging)
            {
                Debug.Log("Staging is on you would request from this url:\n" + url + "\n The data would look like this:\n" + guh.getDataString());
            }
            else
            {
                gwr.unityWebRequest = new UnityWebRequest();
                using (gwr.unityWebRequest)
                {
                    gwr.method        = "POST";
                    gwr.url           = url;
                    gwr.uploadHandler = guh.uploadHandler;
                    gwr.SetRequestHeader("Content-Type", "application/json");
                    if (!string.IsNullOrEmpty(authentification))
                    {
                        gwr.SetRequestHeader("Authorization", authentification);
                    }
                    gwr.chunkedTransfer = false;
                    yield return(gwr.SendWebRequest());

                    if (gwr.isNetworkError || gwr.isHttpError)
                    {
                        Debug.Log("{\"error\": {  \"isHttpError\": \"" + gwr.isHttpError + "\",  \"isNetworkError\": \"" + gwr.isNetworkError + "\" } }");
                    }
                    yield break;
                }
            }
        }
Exemplo n.º 2
0
        //private string locale = null;

        public GoedleAnalytics(
            string api_key,
            string app_key,
            string user_id,
            string app_version,
            string ga_tracking_id,
            string app_name,
            int cd1,
            int cd2,
            string cd_event,
            GoedleHttpClient gio_http_client,
            IGoedleWebRequest gwr,
            IGoedleUploadHandler guh,
            bool staging,
            bool adaptation_only)    //, string locale)
        {
            _api_key         = api_key;
            _app_key         = app_key;
            _user_id         = user_id;
            _app_version     = app_version;
            _ga_tracking_id  = ga_tracking_id;
            _app_name        = app_name;
            _cd1             = cd1;
            _cd2             = cd2;
            _cd_event        = cd_event;
            _gio_http_client = gio_http_client;
            _gwr             = gwr;
            _staging         = staging;
            _adaptation_only = adaptation_only;
            //this.locale = GoedleLanguageMapping.GetLanguageCode (locale);
            track_launch(guh);
        }
Exemplo n.º 3
0
 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>();
     _guh             = Substitute.For <IGoedleUploadHandler>();
     _gw              = Substitute.For <IGoedleWebRequest>();
 }
Exemplo n.º 4
0
        /*
         * 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 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);
        }
Exemplo n.º 6
0
        public IEnumerator basicPostClient(string content, IGoedleWebRequest gwr, IGoedleUploadHandler guh)
        {
            guh.add(content);
            gwr.unityWebRequest = new UnityWebRequest();
            using (gwr.unityWebRequest)
            {
                gwr.method        = "POST";
                gwr.url           = "url";
                gwr.uploadHandler = guh.uploadHandler;
                gwr.unityWebRequest.SetRequestHeader("Content-Type", "application/json");
                gwr.chunkedTransfer = false;
                yield return(gwr.unityWebRequest.SendWebRequest());

                if (gwr.isNetworkError || gwr.isHttpError)
                {
                    Debug.LogError("isHttpError: " + gwr.isHttpError);
                    Debug.LogError("isNetworkError: " + gwr.isNetworkError);
                }
            }
        }
Exemplo n.º 7
0
        public IEnumerator getRequest(string url, IGoedleWebRequest gwr, 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;
                    yield return(gwr.SendWebRequest());

                    if (gwr.isNetworkError || gwr.isHttpError)
                    {
                        Debug.Log("{\"error\": {  \"isHttpError\": \"" + gwr.isHttpError + "\",  \"isNetworkError\": \"" + gwr.isNetworkError + "\" } }");
                    }
                    yield break;
                }
            }
        }
Exemplo n.º 8
0
 public void sendPost(string content, IGoedleWebRequest gwr, IGoedleUploadHandler guh)
 {
     StartCoroutine(basicPostClient(content, gwr, guh));
 }
Exemplo n.º 9
0
 public void SetUp()
 {
     _http_client = (new GameObject("BasicHttpClient")).AddComponent <BasicHttpClient>();
     _guh         = Substitute.For <IGoedleUploadHandler>();
     _gw          = Substitute.For <IGoedleWebRequest>();
 }
Exemplo n.º 10
0
 public void sendPost(string url, string authentification, IGoedleWebRequest gwr, IGoedleUploadHandler guh, bool staging)
 {
     StartCoroutine(postJSONRequest(url, authentification, gwr, guh, staging));
 }
Exemplo n.º 11
0
 public void sendGet(string url, IGoedleWebRequest gwr, bool staging)
 {
     StartCoroutine(getRequest(url, gwr, staging));
 }
Exemplo n.º 12
0
 public void requestStrategy(string url, GoedleAnalytics ga, IGoedleWebRequest gwr, IGoedleDownloadBuffer gdb, bool staging)
 {
     StartCoroutine(getJSONResponse(url, ga, gwr, gdb, staging));
 }