Beispiel #1
0
        /// <summary>Synchronously send the ListItemRatings request</summary>
        /// <param name="request">Request to be sent</param>
        /// <returns>Response from the API</returns>
        public IEnumerable <Rating> Send(ListItemRatings request)
        {
            var task   = Task.Run(async() => await SendAsync(request));
            var result = task.WaitAndUnwrapException();

            return(result);
        }
        /// <summary>Synchronously send the ListItemRatings request</summary>
        /// <param name="request">Request to be sent</param>
        /// <returns>Response from the API</returns>
        public IEnumerable <Rating> Send(ListItemRatings request)
        {
            var task = SendAsync(request);

            RaiseExceptionOnFault(task);
            return(task.Result);
        }
        public void TestListItemRatings()
        {
            ListItemRatings      req;
            Request              req2;
            IEnumerable <Rating> resp;

            // it 'lists interactions'
            req  = new ListItemRatings("item");
            resp = client.Send(req);
            Assert.Equal(1, resp.Count());
            Assert.Equal("item", resp.ElementAt(0).ItemId);
            Assert.Equal("user", resp.ElementAt(0).UserId);
        }
        public async void TestListItemRatings()
        {
            ListItemRatings      req;
            Request              req2;
            IEnumerable <Rating> resp;

            // it 'lists interactions'
            req  = new ListItemRatings("item");
            resp = await client.SendAsync(req);

            Assert.Single(resp);
            Assert.Equal("item", resp.ElementAt(0).ItemId);
            Assert.Equal("user", resp.ElementAt(0).UserId);
        }
Beispiel #5
0
        public async void TestListItemRatingsAsync()
        {
            ListItemRatings      req;
            Request              req2;
            IEnumerable <Rating> resp;

            // it 'lists interactions'
            req = new ListItemRatings("item");
            System.Threading.Thread.Sleep(10000);
            resp = await client.SendAsync(req);

            Assert.Equal(1, resp.Count());
            Assert.Equal("item", resp.ElementAt(0).ItemId);
            Assert.Equal("user", resp.ElementAt(0).UserId);
        }
        /// <summary>Send the ListItemRatings request</summary>
        /// <param name="request">Request to be sent</param>
        /// <returns>Response from the API</returns>
        public async Task <IEnumerable <Rating> > SendAsync(ListItemRatings request)
        {
            var json = await SendRequestAsync(request).ConfigureAwait(false);

            return(ParseResponse(json, request));
        }
 /// <summary>Parse JSON response</summary>
 /// <param name="json">JSON string from the API</param>
 /// <param name="request">Request sent to the API</param>
 /// <returns>Parsed response</returns>
 protected IEnumerable <Rating> ParseResponse(string json, ListItemRatings request)
 {
     return(JsonConvert.DeserializeObject <Rating[]>(json));
 }
        /// <summary>Send the ListItemRatings request</summary>
        /// <param name="request">Request to be sent</param>
        /// <returns>Response from the API</returns>
        public IEnumerable <Rating> Send(ListItemRatings request)
        {
            var json = SendRequest(request);

            return(ParseResponse(json, request));
        }