コード例 #1
0
        public async Task <IList <ParticipantHistoryObject> > Get(DateTimeOffset timeFilterStart, DateTimeOffset timeFilterEnd)
        {
            var stringTask = await _httpClient.GetAsync(
                new Uri(
                    $"{ApiUri}{_apiParticipants}&end_time__gte={timeFilterStart.ToString("yyyy-MM-ddTHH:mm:ss")}&end_time__lt={timeFilterEnd.ToString("yyyy-MM-ddTHH:mm:ss")}"));

            ParticipantHistoryResponse      participantHistoryModel = new ParticipantHistoryResponse();
            List <ParticipantHistoryObject> participantHistoryList  = new List <ParticipantHistoryObject>();

            participantHistoryModel = JsonConvert.DeserializeObject <ParticipantHistoryResponse>(stringTask.Content.ReadAsStringAsync().Result);

            // Add all the participant objects to the list
            foreach (var participant in participantHistoryModel.ParticipantHistoryObject)
            {
                participantHistoryList.Add(participant);
            }

            // If there are more pages, page through them using the 'next' pointer
            while (participantHistoryModel.MetaObject.Next != null)
            {
                // Use the 'next' pointer to get the next page
                stringTask = await _httpClient.GetAsync(new Uri(ApiUri + participantHistoryModel.MetaObject.Next));

                participantHistoryModel = JsonConvert.DeserializeObject <ParticipantHistoryResponse>(stringTask.Content.ReadAsStringAsync().Result);

                // Add all the participant objects to the list
                foreach (var participant in participantHistoryModel.ParticipantHistoryObject)
                {
                    participantHistoryList.Add(participant);
                }
            }

            return(participantHistoryList);
        }
コード例 #2
0
        public async Task <IList <ParticipantHistoryObject> > Get()
        {
            var stringTask = await _httpClient.GetAsync(new Uri(ApiUri + _apiParticipants));

            ParticipantHistoryResponse      participantHistoryResponse = new ParticipantHistoryResponse();
            List <ParticipantHistoryObject> participantHistoryList     = new List <ParticipantHistoryObject>();

            participantHistoryResponse = JsonConvert.DeserializeObject <ParticipantHistoryResponse>(stringTask.Content.ReadAsStringAsync().Result);

            // Add all the participant objects to the list
            foreach (var participant in participantHistoryResponse.ParticipantHistoryObject)
            {
                participantHistoryList.Add(participant);
            }

            // If there are more pages, page through them using the 'next' pointer
            while (participantHistoryResponse.MetaObject.Next != null)
            {
                // Use the 'next' pointer to get the next page
                stringTask = await _httpClient.GetAsync(new Uri(ApiUri + participantHistoryResponse.MetaObject.Next));

                participantHistoryResponse = JsonConvert.DeserializeObject <ParticipantHistoryResponse>(stringTask.Content.ReadAsStringAsync().Result);

                // Add all the participant objects to the list
                foreach (var participant in participantHistoryResponse.ParticipantHistoryObject)
                {
                    participantHistoryList.Add(participant);
                }
            }

            return(participantHistoryList);
        }