Exemple #1
0
        public static void FetchGroupNames(string userId, string groupType, Action <List <string> > successCallback = null, Action <string> errorCallback = null)
        {
            ApiModelListContainer <ApiGroup> apiModelListContainer = new ApiModelListContainer <ApiGroup>();

            apiModelListContainer.OnSuccess = delegate(ApiContainer c)
            {
                List <string> list = new List <string>();
                foreach (ApiGroup responseModel in (c as ApiModelListContainer <ApiGroup>).ResponseModels)
                {
                    list.Add(responseModel.name);
                }
                if (successCallback != null)
                {
                    successCallback(list);
                }
            };
            apiModelListContainer.OnError = delegate(ApiContainer c)
            {
                if (errorCallback != null)
                {
                    errorCallback(c.Error);
                }
            };
            ApiModelListContainer <ApiGroup> responseContainer = apiModelListContainer;
            Dictionary <string, object>      dictionary        = new Dictionary <string, object>();

            dictionary["ownerId"] = userId;
            if (groupType != null)
            {
                dictionary["type"] = groupType;
            }
            API.SendGetRequest("favorite/groups", responseContainer, dictionary, disableCache: true);
        }
Exemple #2
0
        public static void FetchFeedback(Action <IEnumerable <ApiFeedback> > successCallback, Action <string> errorCallback)
        {
            ApiModelListContainer <ApiFeedback> apiModelListContainer = new ApiModelListContainer <ApiFeedback>();

            apiModelListContainer.OnSuccess = delegate(ApiContainer c)
            {
                if (successCallback != null)
                {
                    successCallback((c as ApiModelListContainer <ApiFeedback>).ResponseModels);
                }
            };
            apiModelListContainer.OnError = delegate(ApiContainer c)
            {
                if (errorCallback != null)
                {
                    errorCallback(c.Error);
                }
            };
            ApiContainer responseContainer = apiModelListContainer;

            API.SendGetRequest("/users/" + APIUser.CurrentUser.id + "/feedback", responseContainer, null, disableCache: true);
        }
Exemple #3
0
        public static void FetchWorldFeedback(string worldId, int version, ContentType contentType, Action <IEnumerable <ApiFeedback> > successCallback, Action <string> errorCallback)
        {
            ApiModelListContainer <ApiFeedback> apiModelListContainer = new ApiModelListContainer <ApiFeedback>();

            apiModelListContainer.OnSuccess = delegate(ApiContainer c)
            {
                if (successCallback != null)
                {
                    successCallback((c as ApiModelListContainer <ApiFeedback>).ResponseModels);
                }
            };
            apiModelListContainer.OnError = delegate(ApiContainer c)
            {
                if (errorCallback != null)
                {
                    errorCallback(c.Error);
                }
            };
            ApiContainer responseContainer = apiModelListContainer;

            API.SendGetRequest("/users/" + APIUser.CurrentUser.id + "/feedback?contentType=world&contentId=" + worldId + "&contentVersion=" + version.ToString(), responseContainer, null, disableCache: true);
        }
Exemple #4
0
        private static void FetchList(string endpoint, Action <IEnumerable <ApiPlayerModeration> > successCallback, Action <string> errorCallback)
        {
            ApiModelListContainer <ApiPlayerModeration> apiModelListContainer = new ApiModelListContainer <ApiPlayerModeration>();

            apiModelListContainer.OnSuccess = delegate(ApiContainer c)
            {
                if (successCallback != null)
                {
                    successCallback((c as ApiModelListContainer <ApiPlayerModeration>).ResponseModels);
                }
            };
            apiModelListContainer.OnError = delegate(ApiContainer c)
            {
                Debug.LogError((object)("Could not fetch moderations with error - " + c.Error));
                if (errorCallback != null)
                {
                    errorCallback(c.Error);
                }
            };
            ApiModelListContainer <ApiPlayerModeration> responseContainer = apiModelListContainer;

            API.SendGetRequest(endpoint, responseContainer, null, disableCache: false, 120f);
        }
Exemple #5
0
        public static void FetchUploadedWorlds(Action <IEnumerable <ApiWorld> > successCallback, Action <string> errorCallback)
        {
            ApiModelListContainer <ApiWorld> apiModelListContainer = new ApiModelListContainer <ApiWorld>();

            apiModelListContainer.OnSuccess = delegate(ApiContainer c)
            {
                if (successCallback != null)
                {
                    successCallback((c as ApiModelListContainer <ApiWorld>).ResponseModels);
                }
            };
            apiModelListContainer.OnError = delegate(ApiContainer c)
            {
                if (errorCallback != null)
                {
                    errorCallback(c.Error);
                }
            };
            ApiModelListContainer <ApiWorld> responseContainer = apiModelListContainer;
            Dictionary <string, object>      dictionary        = new Dictionary <string, object>();

            dictionary["user"] = "******";
            API.SendGetRequest("worlds/", responseContainer, dictionary, disableCache: true);
        }
Exemple #6
0
        public static void FetchGroupMemberIds(string userId, GroupType groupType, Action <List <string> > successCallback = null, Action <string> errorCallback = null, string tag = null)
        {
            if (groupType.value == "world" || groupType.value == "avatar" || groupType.value == "friend")
            {
                int totalGroupsToFetch = 1;
                if (string.IsNullOrEmpty(tag))
                {
                    switch (groupType.value)
                    {
                    case "world":
                        totalGroupsToFetch = 4;
                        break;

                    case "avatar":
                        totalGroupsToFetch = 1;
                        break;

                    case "friend":
                        totalGroupsToFetch = 3;
                        break;
                    }
                }
                List <string> totalGroupMemberIds = new List <string>();
                int           groupsFetched       = 0;
                bool          locked = false;
                for (int i = 0; i < totalGroupsToFetch; i++)
                {
                    ApiModelListContainer <ApiFavorite> apiModelListContainer = new ApiModelListContainer <ApiFavorite>();
                    apiModelListContainer.OnSuccess = delegate(ApiContainer c)
                    {
                        while (locked)
                        {
                        }
                        locked = true;
                        List <string> list = new List <string>();
                        foreach (ApiFavorite responseModel in (c as ApiModelListContainer <ApiFavorite>).ResponseModels)
                        {
                            if (!list.Contains(responseModel.favoriteId))
                            {
                                list.Add(responseModel.favoriteId);
                            }
                        }
                        totalGroupMemberIds.AddRange(list);
                        locked = false;
                        groupsFetched++;
                        if (successCallback != null && groupsFetched == totalGroupsToFetch)
                        {
                            successCallback(totalGroupMemberIds);
                        }
                    };
                    apiModelListContainer.OnError = delegate(ApiContainer c)
                    {
                        if (errorCallback != null)
                        {
                            errorCallback(c.Error);
                        }
                    };
                    ApiModelListContainer <ApiFavorite> responseContainer = apiModelListContainer;
                    string target = "favorites";
                    Dictionary <string, object> dictionary = null;
                    dictionary            = new Dictionary <string, object>();
                    dictionary["ownerId"] = userId;
                    dictionary["type"]    = groupType.value;
                    int num = 0;
                    switch (groupType.value)
                    {
                    case "world":
                        num = 32;
                        break;

                    case "avatar":
                        num = 16;
                        break;

                    case "friend":
                        num = 32;
                        break;
                    }
                    if (!string.IsNullOrEmpty(tag))
                    {
                        dictionary["tag"] = tag;
                    }
                    dictionary["n"]      = num;
                    dictionary["offset"] = i * num;
                    API.SendGetRequest(target, responseContainer, dictionary, disableCache: true);
                }
            }
            else
            {
                Debug.LogError((object)("Cannot fetch group member ids " + groupType.value + " b/c it's not implemented yet."));
            }
        }
Exemple #7
0
        public static void FetchList(Action <IEnumerable <ApiWorld> > successCallback, Action <string> errorCallback = null, SortHeading heading = SortHeading.Featured, SortOwnership owner = SortOwnership.Any, SortOrder order = SortOrder.Descending, int offset = 0, int count = 10, string search = "", string[] tags = null, string[] excludeTags = null, string[] userTags = null, string userId = "", ReleaseStatus releaseStatus = ReleaseStatus.Public, string includePlatforms = null, string excludePlatforms = null, bool disableCache = false, bool compatibleVersionsOnly = true)
        {
            string endpoint = "worlds";
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            switch (heading)
            {
            case SortHeading.Featured:
                dictionary.Add("sort", "order");
                dictionary.Add("featured", "true");
                break;

            case SortHeading.Trending:
                dictionary.Add("sort", "popularity");
                dictionary.Add("featured", "false");
                break;

            case SortHeading.Updated:
                dictionary.Add("sort", "updated");
                break;

            case SortHeading.Created:
                dictionary.Add("sort", "created");
                break;

            case SortHeading.Publication:
                dictionary.Add("sort", "publicationDate");
                break;

            case SortHeading.Shuffle:
                dictionary.Add("sort", "shuffle");
                break;

            case SortHeading.Active:
                endpoint = "worlds/active";
                break;

            case SortHeading.Recent:
                endpoint = "worlds/recent";
                break;

            case SortHeading.Playlist:
                endpoint = "worlds/favorites";
                dictionary.Add("userId", userId);
                break;

            case SortHeading.Favorite:
                endpoint = "worlds/favorites";
                break;

            case SortHeading.Labs:
                dictionary.Add("sort", "labsPublicationDate");
                break;

            case SortHeading.Heat:
                dictionary.Add("sort", "heat");
                dictionary.Add("featured", "false");
                break;
            }
            switch (owner)
            {
            case SortOwnership.Mine:
                dictionary.Add("user", "me");
                break;

            case SortOwnership.Friend:
                dictionary.Add("userId", userId);
                break;
            }
            dictionary.Add("n", count);
            switch (order)
            {
            case SortOrder.Ascending:
                dictionary.Add("order", "ascending");
                break;

            case SortOrder.Descending:
                dictionary.Add("order", "descending");
                break;
            }
            dictionary.Add("offset", offset);
            if (!string.IsNullOrEmpty(search))
            {
                dictionary.Add("search", search);
            }
            int num  = (tags != null) ? tags.Length : 0;
            int num2 = (userTags != null) ? userTags.Length : 0;

            if (num + num2 > 0)
            {
                string[] array = new string[num + num2];
                if (num > 0)
                {
                    tags.CopyTo(array, 0);
                }
                if (num2 > 0)
                {
                    userTags.CopyTo(array, num);
                }
                dictionary.Add("tag", string.Join(",", array));
            }
            if (excludeTags != null && excludeTags.Length > 0)
            {
                dictionary.Add("notag", string.Join(",", excludeTags));
            }
            dictionary.Add("releaseStatus", releaseStatus.ToString().ToLower());
            if (compatibleVersionsOnly)
            {
                dictionary.Add("maxUnityVersion", VERSION.UnityVersion);
                dictionary.Add("minUnityVersion", MIN_LOADABLE_VERSION.UnityVersion);
                dictionary.Add("maxAssetVersion", VERSION.ApiVersion);
                dictionary.Add("minAssetVersion", MIN_LOADABLE_VERSION.ApiVersion);
            }
            if (includePlatforms != null || excludePlatforms != null)
            {
                if (includePlatforms != null)
                {
                    dictionary.Add("platform", includePlatforms);
                }
                if (excludePlatforms != null)
                {
                    dictionary.Add("noplatform", excludePlatforms);
                }
            }
            ApiModelListContainer <ApiWorld> apiModelListContainer = new ApiModelListContainer <ApiWorld>();

            apiModelListContainer.OnSuccess = delegate(ApiContainer c)
            {
                if (successCallback != null)
                {
                    successCallback((c as ApiModelListContainer <ApiWorld>).ResponseModels);
                }
            };
            apiModelListContainer.OnError = delegate(ApiContainer c)
            {
                Debug.LogError((object)("Could not fetch worlds, with error - " + c.Error));
                if (errorCallback != null)
                {
                    errorCallback(c.Error);
                }
            };
            ApiModelListContainer <ApiWorld> responseContainer = apiModelListContainer;

            API.SendRequest(endpoint, HTTPMethods.Get, responseContainer, dictionary, authenticationRequired: true, disableCache, 180f);
        }
Exemple #8
0
        public static void FetchList(Action <IEnumerable <ApiAvatar> > successCallback, Action <string> errorCallback, Owner owner, ReleaseStatus relStatus = ReleaseStatus.All, string search = null, int number = 10, int offset = 0, SortHeading heading = SortHeading.None, SortOrder order = SortOrder.Descending, string includePlatforms = null, string excludePlatforms = null, bool disableCache = false, bool areFavorites = false, string tags = null, bool compatibleVersionsOnly = true)
        {
            string endpoint = "avatars";
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            if (owner == Owner.Licensed)
            {
                dictionary.Add("n", number);
                dictionary.Add("offset", offset);
                endpoint = "avatars/licensed";
            }
            else
            {
                if (areFavorites)
                {
                    endpoint = "avatars/favorites";
                }
                if (owner == Owner.Mine)
                {
                    dictionary.Add("user", "me");
                }
                if (owner == Owner.Public)
                {
                    dictionary.Add("featured", "true");
                }
                if (owner == Owner.Developer)
                {
                    dictionary.Add("tag", "admin_developer");
                }
                dictionary.Add("releaseStatus", relStatus.ToString().ToLower());
                if (search != null)
                {
                    dictionary.Add("search", search);
                }
                dictionary.Add("n", number);
                dictionary.Add("offset", offset);
                if (heading != 0)
                {
                    dictionary.Add("sort", heading.ToString().ToLower());
                }
                switch (order)
                {
                case SortOrder.Ascending:
                    dictionary.Add("order", "ascending");
                    break;

                case SortOrder.Descending:
                    dictionary.Add("order", "descending");
                    break;
                }
                if (compatibleVersionsOnly)
                {
                    dictionary.Add("maxUnityVersion", VERSION.UnityVersion);
                    dictionary.Add("minUnityVersion", MIN_LOADABLE_VERSION.UnityVersion);
                    dictionary.Add("maxAssetVersion", VERSION.ApiVersion);
                    dictionary.Add("minAssetVersion", MIN_LOADABLE_VERSION.ApiVersion);
                }
                if (includePlatforms != null || excludePlatforms != null)
                {
                    if (includePlatforms != null)
                    {
                        dictionary.Add("platform", includePlatforms);
                    }
                    if (excludePlatforms != null)
                    {
                        dictionary.Add("noplatform", excludePlatforms);
                    }
                }
                if (tags != null)
                {
                    dictionary.Add("tag", tags);
                }
            }
            ApiModelListContainer <ApiAvatar> apiModelListContainer = new ApiModelListContainer <ApiAvatar>();

            apiModelListContainer.OnSuccess = delegate(ApiContainer c)
            {
                if (successCallback != null)
                {
                    successCallback((c as ApiModelListContainer <ApiAvatar>).ResponseModels);
                }
            };
            apiModelListContainer.OnError = delegate(ApiContainer c)
            {
                Logger.Log("Could not fetch avatars with error - " + c.Error);
                if (errorCallback != null)
                {
                    errorCallback(c.Error);
                }
            };
            ApiModelListContainer <ApiAvatar> responseContainer = apiModelListContainer;

            API.SendRequest(endpoint, HTTPMethods.Get, responseContainer, dictionary, authenticationRequired: true, disableCache, 180f);
        }