Beispiel #1
0
        public IEnumerator GetWithToken(string url, Action <string> onSuccess, Action <string, string> onFail = null)
        {
            UnityWebRequest www = UnityWebRequest.Get(Constants.BaseUrl + url);

            AddValidationHeader(www);
            string currentToken = null;

            if (TacoManager.User == null)
            {
                currentToken = TacoManager.GetPreferenceString(UserPreferences.userToken);
            }
            else
            {
                currentToken = TacoManager.User.token;
            }

            www.SetRequestHeader("x-access-token", currentToken);

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.responseCode == 500)
            {
                Debug.Log("www.isError =" + www.error);

                if (onFail != null)
                {
                    onFail(www.downloadHandler.text, www.error);
                }
            }
            else
            {
                onSuccess(www.downloadHandler.text);
            }
        }
Beispiel #2
0
        public IEnumerator InviteFriends(Action <string> onSuccess, Action <string, string> onFail = null)
        {
            Tournament t    = TacoManager.Target;
            WWWForm    form = new WWWForm();

            string currentToken = null;

            if (TacoManager.User == null)
            {
                currentToken = TacoManager.GetPreferenceString(UserPreferences.userToken);
            }
            else
            {
                currentToken = TacoManager.User.token;
            }

            form.AddField("fromUserId", TacoManager.User.userId);
            form.AddField("fromEmail", TacoManager.User.email);
            form.AddField("baseUrl", "baysidegames.com");
            form.AddField("emails", t.invitedEmails [0]);
            form.AddField("tournamentId", t.id);

            UnityWebRequest www = UnityWebRequest.Post(Constants.BaseUrl + "api/friends/invite/tournament", form);

            www.SetRequestHeader("x-access-token", currentToken);

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.responseCode == 500)
            {
                if (onFail != null)
                {
                    onFail(www.downloadHandler.text, www.error);
                }
            }
            else
            {
                onSuccess(www.downloadHandler.text);
            }
        }
Beispiel #3
0
        public IEnumerator RemoveFriend(string email, int friendId, int tournamentId, Action <string> onSuccess, Action <string, string> onFail = null)
        {
            WWWForm form = new WWWForm();
            string  currentToken;

            if (TacoManager.User == null)
            {
                currentToken = TacoManager.GetPreferenceString(UserPreferences.userToken);
            }
            else
            {
                currentToken = TacoManager.User.token;
            }

            form.AddField("friendId", friendId);
            form.AddField("tourId", tournamentId);
            form.AddField("email", email);

            UnityWebRequest www = UnityWebRequest.Post(Constants.BaseUrl + "api/friends/remove2", form);

            www.SetRequestHeader("x-access-token", currentToken);

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.responseCode == 500)
            {
                if (onFail != null)
                {
                    onFail(www.downloadHandler.text, www.error);
                }
            }
            else
            {
                onSuccess(www.downloadHandler.text);
            }
        }