コード例 #1
0
        public async Task <LeaderBoardResult> GetLeaderBoardResultsAsync(int segmentId, searchMetaData searchMetaData)
        {
            string uri = baseUrl +
                         segmentsUrl + "/" +
                         segmentId + "/" +
                         leaderBoardUrl + "?" +
                         "per_page=" + searchMetaData.per_page + "&" +
                         "date_range=" + searchMetaData.date_range + "&" +
                         "gender=" + searchMetaData.Gender + "&" +
                         "age_group=" + searchMetaData.age_group + "&" +
                         "weight_class=" + searchMetaData.weight_class + "&" +
                         accessTokenQuery + accessToken;

            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync(uri);

                var data = response.Content.ReadAsStringAsync().Result;
                LeaderBoardResult leaderBoardResult = new LeaderBoardResult();
                try
                {
                    leaderBoardResult = JsonConvert.DeserializeObject <LeaderBoardResult>(data);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                return(leaderBoardResult);
            }
        }
コード例 #2
0
 public void SetUp()
 {
     expectedLeaderBoardResultTask = Task.Run(() => expectedLeaderBoardResult);
     TestSegmentJsonArray          = Task.Run(() => new segmentJsonArray());
     expectedLeaderBoardResult     = new LeaderBoardResult()
     {
         effort_count = 999
     };
     emptyCoords = new List <Coordinates>();
 }
コード例 #3
0
        public async Task <LeaderBoardResult> GetLeaderBoardResultsAsync(int segmentId)
        {
            int    perPage   = ApiDetails.MaxResultsPerPage;
            string dateRange = "this_week";

            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync(baseUrl + segmentsUrl + "/" + segmentId + "/" + leaderBoardUrl + "?" + perPageQuery + perPage + "&" + dateRangeQuery + dateRange + "&" + accessTokenQuery + accessToken);

                var data = response.Content.ReadAsStringAsync().Result;
                LeaderBoardResult leaderBoardResult = new LeaderBoardResult();
                try
                {
                    leaderBoardResult = JsonConvert.DeserializeObject <LeaderBoardResult>(data);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                return(leaderBoardResult);
            }
        }