public static string GetParameter(this FriendsSearchType provider)
        {
            switch (provider)
            {
            case FriendsSearchType.Added: return("friends");

            case FriendsSearchType.Pending: return("friend_requested_by");

            case FriendsSearchType.Requested: return("friend_requested");

            case FriendsSearchType.Blocked: return("blocked");

            case FriendsSearchType.BlocksMe: return("blocked_by");

            default: return(string.Empty);
            }
        }
        /// <summary>
        /// Gets friends of authenticated user.
        /// </summary>
        /// <remarks> Swagger method name:<c>Get Friends</c>.</remarks>
        /// <see cref="https://developers.xsolla.com/user-account-api/user-friends/get-friends"/>.
        /// <param name="token">JWT from Xsolla Login.</param>
        /// <param name="type">Friends type.</param>
        /// <param name="sortType">Condition for sorting users.</param>
        /// <param name="order">Condition for sorting users.</param>
        /// <param name="count">Maximum friends.</param>
        /// <param name="onSuccess">Successful operation callback.</param>
        /// <param name="onError">Failed operation callback.</param>
        public void GetUserFriends(
            string token,
            FriendsSearchType type,
            FriendsSearchResultsSort sortType   = FriendsSearchResultsSort.ByNickname,
            FriendsSearchResultsSortOrder order = FriendsSearchResultsSortOrder.Asc,
            int count = 100,
            Action <List <UserFriendEntity> > onSuccess = null, Action <Error> onError = null)
        {
            if (count <= 0)
            {
                Debug.LogError($"Can not requests friends with count {count}");
                return;
            }
            var url = string.Format(URL_USER_GET_FRIENDS, type.GetParameter(), sortType.GetParameter(), order.GetParameter(), USER_FRIENDS_DEFAULT_PAGINATION_LIMIT);

            StartCoroutine(GetUserFriendsCoroutine(token, url, count, onSuccess, onError));
        }
Esempio n. 3
0
 private void GetUsersByType(FriendsSearchType searchType, UserRelationship relationship,
                             Action <List <FriendModel> > onSuccess = null, Action <Error> onError = null)
 {
     XsollaLogin.Instance.GetUserFriends(Token.Instance,
                                         searchType, FRIENDS_SORT_TYPE, FRIENDS_SORT_ORDER, MAX_FRIENDS_COUNT, friends =>
     {
         onSuccess?.Invoke(friends.Select(f =>
         {
             var result = ConvertFriendEntity(f, relationship);
             // this method used at this place for fastest image loading
             if (!string.IsNullOrEmpty(result.AvatarUrl))
             {
                 ImageLoader.Instance.GetImageAsync(result.AvatarUrl, null);
             }
             return(result);
         }).ToList());
     }, onError);
 }