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); }
_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!")); } } }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }