Exemplo n.º 1
0
        public static Promise <FetchChannelMessagesResponse> FetchChannelMessages(string channelId, string before = null,
                                                                                  string after = null)
        {
            D.assert(before == null || after == null);
            var promise = new Promise <FetchChannelMessagesResponse>();
            var para    = new Dictionary <string, object> {
                { "needDeleted", "true" }
            };

            if (before != null)
            {
                para.Add("before", value: before);
            }
            else if (after != null)
            {
                para.Add("after", value: after);
            }
            var request = HttpManager.GET($"{Config.apiAddress_cn}{Config.apiPath}/channels/{channelId}/messages",
                                          parameter: para);

            HttpManager.resume(request: request).Then(responseText => {
                promise.Resolve(JsonConvert.DeserializeObject <FetchChannelMessagesResponse>(value: responseText));
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 2
0
        _FetchSocketUrl(Promise <string> promise)
        {
            var request = HttpManager.GET(Config.apiAddress + "/api/socketgw");

            yield return(request.SendWebRequest());

            if (request.isNetworkError)
            {
                // something went wrong
                promise.Reject(new Exception(request.error));
            }
            else if (request.responseCode != 200)
            {
                // or the response is not OK
                promise.Reject(new Exception(request.downloadHandler.text));
            }
            else
            {
                // Format output and resolve promise
                var responseText = request.downloadHandler.text;
                var response     = JsonConvert.DeserializeObject <FetchSocketUrlResponse>(responseText);
                if (!string.IsNullOrEmpty(response.url))
                {
                    promise.Resolve(response.url);
                }
                else
                {
                    promise.Reject(new Exception("No user under this username found!"));
                }
            }
        }
Exemplo n.º 3
0
        public static Promise <FetchFollowArticlesResponse> FetchFollowArticles(int pageNumber, string beforeTime,
                                                                                string afterTime, bool isFirst, bool isHot)
        {
            var promise = new Promise <FetchFollowArticlesResponse>();
            Dictionary <string, object> para;

            if (isFirst)
            {
                para = null;
            }
            else
            {
                if (isHot)
                {
                    para = new Dictionary <string, object> {
                        { "hotPage", pageNumber }
                    };
                }
                else
                {
                    para = new Dictionary <string, object> {
                        { "beforeTime", beforeTime },
                        { "afterTime", afterTime }
                    };
                }
            }
            var request = HttpManager.GET($"{Config.apiAddress}{Config.apiPath}/feeds", parameter: para);

            HttpManager.resume(request: request).Then(responseText => {
                var followArticlesResponse =
                    JsonConvert.DeserializeObject <FetchFollowArticlesResponse>(value: responseText);
                promise.Resolve(value: followArticlesResponse);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 4
0
        public static Promise <FetchChannelMemberResponse> FetchChannelMember(string channelId, string userId)
        {
            var promise = new Promise <FetchChannelMemberResponse>();
            var request = HttpManager.GET($"{Config.apiAddress}{Config.apiPath}/channels/{channelId}/members/{userId}");

            HttpManager.resume(request: request).Then(responseText => {
                promise.Resolve(JsonConvert.DeserializeObject <FetchChannelMemberResponse>(value: responseText));
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 5
0
        public static Promise <Splash> FetchSplash()
        {
            var promise = new Promise <Splash>();
            var request = HttpManager.GET($"{Config.apiAddress}{Config.apiPath}/ads");

            HttpManager.resume(request: request).Then(responseText => {
                var splashResponse = JsonConvert.DeserializeObject <Splash>(value: responseText);
                promise.Resolve(value: splashResponse);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 6
0
        public static Promise <Splash> FetchSplash()
        {
            var promise = new Promise <Splash>();
            var request = HttpManager.GET(Config.apiAddress + "/api/live/ads");

            HttpManager.resume(request).Then(responseText => {
                var splashResponse = JsonConvert.DeserializeObject <Splash>(responseText);
                promise.Resolve(splashResponse);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 7
0
        public static Promise <FetchUserProfileResponse> FetchUserProfile(string userId)
        {
            var promise = new Promise <FetchUserProfileResponse>();
            var request = HttpManager.GET($"{Config.apiAddress}/api/connectapp/u/{userId}");

            HttpManager.resume(request: request).Then(responseText => {
                var userProfileResponse = JsonConvert.DeserializeObject <FetchUserProfileResponse>(value: responseText);
                promise.Resolve(value: userProfileResponse);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 8
0
        public static Promise <RankData> FetchGameDetail(string gameId)
        {
            var promise = new Promise <RankData>();
            var request = HttpManager.GET($"{Config.apiAddress_cn}{Config.apiPath}/rankList/game/{gameId}");

            HttpManager.resume(request: request).Then(responseText => {
                var gameDetailResponse = JsonConvert.DeserializeObject <RankData>(value: responseText);
                promise.Resolve(value: gameDetailResponse);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 9
0
        public static IPromise <IEvent> FetchEventDetail(string eventId)
        {
            var promise = new Promise <IEvent>();
            var request = HttpManager.GET($"{Config.apiAddress}{Config.apiPath}/events/{eventId}");

            HttpManager.resume(request: request).Then(responseText => {
                var eventDetail = JsonConvert.DeserializeObject <IEvent>(value: responseText);
                promise.Resolve(value: eventDetail);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 10
0
        public static Promise <FetchNotificationResponse> FetchNotifications(int pageNumber)
        {
            var promise = new Promise <FetchNotificationResponse>();
            var request = HttpManager.GET(Config.apiAddress + "/api/notifications/app?page=" + pageNumber);

            HttpManager.resume(request).Then(responseText => {
                var notificationResponse = JsonConvert.DeserializeObject <FetchNotificationResponse>(responseText);
                promise.Resolve(notificationResponse);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 11
0
        public static Promise <FetchArticleDetailResponse> FetchArticleDetail(string articleId)
        {
            var promise = new Promise <FetchArticleDetailResponse>();
            var request = HttpManager.GET(Config.apiAddress + "/api/p/" + articleId + "?view=true");

            HttpManager.resume(request).Then(responseText => {
                var articleDetailResponse = JsonConvert.DeserializeObject <FetchArticleDetailResponse>(responseText);
                promise.Resolve(articleDetailResponse);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 12
0
        public static Promise <FetchTeamResponse> FetchTeam(string teamId)
        {
            var promise = new Promise <FetchTeamResponse>();
            var request = HttpManager.GET($"{Config.apiAddress}{Config.apiPath}/teams/{teamId}");

            HttpManager.resume(request: request).Then(responseText => {
                var teamResponse = JsonConvert.DeserializeObject <FetchTeamResponse>(value: responseText);
                promise.Resolve(value: teamResponse);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 13
0
        public static IPromise <IEvent> FetchEventDetail(string eventId)
        {
            var promise = new Promise <IEvent>();
            var request = HttpManager.GET(Config.apiAddress + "/api/live/events/" + eventId);

            HttpManager.resume(request).Then(responseText => {
                var liveDetail = JsonConvert.DeserializeObject <IEvent>(responseText);
                promise.Resolve(liveDetail);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 14
0
        public static Promise <List <PopularSearch> > PopularSearch()
        {
            var promise = new Promise <List <PopularSearch> >();
            var request = HttpManager.GET(Config.apiAddress + "/api/search/popularSearch?searchType=project");

            HttpManager.resume(request).Then(responseText => {
                var popularSearch = JsonConvert.DeserializeObject <List <PopularSearch> >(responseText);
                promise.Resolve(popularSearch);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 15
0
        public static IPromise <FetchInitDataResponse> InitData()
        {
            var promise = new Promise <FetchInitDataResponse>();
            var request = HttpManager.GET($"{Config.apiAddress}{Config.apiPath}/initData");

            HttpManager.resume(request: request).Then(responseText => {
                var initDataResponse = JsonConvert.DeserializeObject <FetchInitDataResponse>(value: responseText);
                promise.Resolve(value: initDataResponse);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 16
0
        public static IPromise <FetchEventsResponse> FetchEvents(int pageNumber, string tab, string mode)
        {
            var promise = new Promise <FetchEventsResponse>();
            var request = HttpManager.GET(Config.apiAddress +
                                          $"/api/events?tab={tab}&page={pageNumber}&mode={mode}&isPublic=true&pageSize=10");

            HttpManager.resume(request).Then(responseText => {
                var eventsResponse = JsonConvert.DeserializeObject <FetchEventsResponse>(responseText);
                promise.Resolve(eventsResponse);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 17
0
        public static IPromise <string> FetchCreateUnityIdUrl()
        {
            var promise = new Promise <string>();
            var request =
                HttpManager.GET(Config.apiAddress + "/api/authUrl?redirect_to=%2F&locale=zh_CN&is_reg=true");

            HttpManager.resume(request).Then(responseText => {
                var urlDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(responseText);
                promise.Resolve(urlDictionary["url"]);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 18
0
        public static IPromise <string> FetchReviewUrl(string platform, string store)
        {
            var promise = new Promise <string>();
            var request =
                HttpManager.GET(Config.apiAddress + $"/api/live/reviewUrl?platform={platform}&store={store}");

            HttpManager.resume(request).Then(responseText => {
                var urlDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(responseText);
                promise.Resolve(urlDictionary["url"]);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 19
0
        public static Promise <FetchSearchResponse> SearchArticle(string keyword, int pageNumber)
        {
            var promise = new Promise <FetchSearchResponse>();
            var request = HttpManager.GET(Config.apiAddress +
                                          $"/api/search?t=project&projectType=article&k=[\"q:{keyword}\"]&searchAllLoadMore=false&page={pageNumber}");

            HttpManager.resume(request).Then(responseText => {
                var searchResponse = JsonConvert.DeserializeObject <FetchSearchResponse>(responseText);
                promise.Resolve(searchResponse);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 20
0
        public static Promise <FetchEventsResponse> FetchMyFutureEvents(int pageNumber)
        {
            var promise = new Promise <FetchEventsResponse>();
            var request = HttpManager.GET(Config.apiAddress +
                                          $"/api/events?tab=my&status=ongoing&mode=offline&page={pageNumber}");

            HttpManager.resume(request).Then(responseText => {
                var eventsResponse = JsonConvert.DeserializeObject <FetchEventsResponse>(responseText);
                promise.Resolve(eventsResponse);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 21
0
        public static IPromise <string> InitData()
        {
            var promise = new Promise <string>();
            var request =
                HttpManager.GET($"{Config.apiAddress}/api/connectapp/initData");

            HttpManager.resume(request).Then(responseText => {
                var dictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(responseText);
                promise.Resolve(dictionary["VS"]);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 22
0
        public static Promise <FetchArticlesResponse> FetchArticles(int offset)
        {
            var promise = new Promise <FetchArticlesResponse>();
            var request = HttpManager.GET(Config.apiAddress +
                                          "/api/getFeedList?language=zh_CN&hottestHasMore=true&feedHasMore=false&isApp=true&hottestOffset=" +
                                          offset);

            HttpManager.resume(request).Then(responseText => {
                var articlesResponse = JsonConvert.DeserializeObject <FetchArticlesResponse>(responseText);
                promise.Resolve(articlesResponse);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 23
0
        public static IPromise <Dictionary <string, string> > FetchVersion(string platform, string store, string version)
        {
            var promise = new Promise <Dictionary <string, string> >();
            var request =
                HttpManager.GET(Config.apiAddress +
                                $"/api/live/version?platform={platform}&store={store}&version={version}");

            HttpManager.resume(request).Then(responseText => {
                var versionDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(responseText);
                promise.Resolve(versionDictionary);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 24
0
        public static Promise <FetchChannelMembersResponse> FetchChannelMembers(string channelId, int offset = 0)
        {
            var promise = new Promise <FetchChannelMembersResponse>();
            var request = HttpManager.GET($"{Config.apiAddress}{Config.apiPath}/channels/{channelId}/members",
                                          parameter: new Dictionary <string, object> {
                { "offset", offset }
            });

            HttpManager.resume(request: request).Then(responseText => {
                promise.Resolve(JsonConvert.DeserializeObject <FetchChannelMembersResponse>(value: responseText));
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 25
0
        public static Promise <FetchChannelMembersResponse> FetchChannelMemberSuggestions(string channelId)
        {
            var promise = new Promise <FetchChannelMembersResponse>();
            var request = HttpManager.GET($"{Config.apiAddress}{Config.apiPath}/channels/{channelId}/members",
                                          new Dictionary <string, object> {
                { "get", "active" }
            });

            HttpManager.resume(request: request).Then(responseText => {
                var members = JsonConvert.DeserializeObject <FetchChannelMembersResponse>(value: responseText);
                promise.Resolve(value: members);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 26
0
        public static Promise <FetchFollowArticlesResponse> FetchFollowArticles(int pageNumber)
        {
            var promise = new Promise <FetchFollowArticlesResponse>();
            var para    = new Dictionary <string, object> {
                { "page", pageNumber }
            };
            var request = HttpManager.GET($"{Config.apiAddress}/api/connectapp/followingUsersArticles", parameter: para);

            HttpManager.resume(request).Then(responseText => {
                var followArticlesResponse = JsonConvert.DeserializeObject <FetchFollowArticlesResponse>(responseText);
                promise.Resolve(followArticlesResponse);
            }).Catch(exception => { promise.Reject(exception); });
            return(promise);
        }
Exemplo n.º 27
0
        public static Promise <FetchGameResponse> FetchGames(int page)
        {
            var promise = new Promise <FetchGameResponse>();
            var para    = new Dictionary <string, object> {
                { "page", page }
            };
            var request = HttpManager.GET($"{Config.apiAddress_cn}{Config.apiPath}/rankList/gameList", parameter: para);

            HttpManager.resume(request: request).Then(responseText => {
                var gamesResponse = JsonConvert.DeserializeObject <FetchGameResponse>(value: responseText);
                promise.Resolve(value: gamesResponse);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 28
0
        public static Promise <FetchUserLikeArticleResponse> FetchUserLikeArticle(string userId, int pageNumber)
        {
            var promise = new Promise <FetchUserLikeArticleResponse>();
            var para    = new Dictionary <string, object> {
                { "page", pageNumber }
            };
            var request = HttpManager.GET($"{Config.apiAddress_cn}{Config.apiPath}/u/{userId}/likes", parameter: para);

            HttpManager.resume(request: request).Then(responseText => {
                var userArticleResponse = JsonConvert.DeserializeObject <FetchUserLikeArticleResponse>(value: responseText);
                promise.Resolve(value: userArticleResponse);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 29
0
        public static Promise <FetchNotificationResponse> FetchNotifications(int pageNumber)
        {
            var promise = new Promise <FetchNotificationResponse>();
            var para    = new Dictionary <string, object> {
                { "page", pageNumber }
            };
            var request = HttpManager.GET($"{Config.apiAddress}{Config.apiPath}/notifications", parameter: para);

            HttpManager.resume(request: request).Then(responseText => {
                var notificationResponse = JsonConvert.DeserializeObject <FetchNotificationResponse>(value: responseText);
                promise.Resolve(value: notificationResponse);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }
Exemplo n.º 30
0
        public static Promise <FetchFollowerResponse> FetchFollower(string userId, int offset)
        {
            var promise = new Promise <FetchFollowerResponse>();
            var para    = new Dictionary <string, object> {
                { "offset", offset }
            };
            var request = HttpManager.GET($"{Config.apiAddress}/api/connectapp/u/{userId}/followers", parameter: para);

            HttpManager.resume(request: request).Then(responseText => {
                var followerResponse = JsonConvert.DeserializeObject <FetchFollowerResponse>(value: responseText);
                promise.Resolve(value: followerResponse);
            }).Catch(exception => promise.Reject(ex: exception));
            return(promise);
        }