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

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

            RaiseExceptionOnFault(task);
            return(task.Result);
        }
        public void TestListUserPurchases()
        {
            ListUserPurchases      req;
            Request                req2;
            IEnumerable <Purchase> resp;

            // it 'lists user interactions'
            req  = new ListUserPurchases("user");
            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 TestListUserPurchases()
        {
            ListUserPurchases      req;
            Request                req2;
            IEnumerable <Purchase> resp;

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

            Assert.Single(resp);
            Assert.Equal("item", resp.ElementAt(0).ItemId);
            Assert.Equal("user", resp.ElementAt(0).UserId);
        }
        public async void TestListUserPurchasesAsync()
        {
            ListUserPurchases      req;
            Request                req2;
            IEnumerable <Purchase> resp;

            // it 'lists user interactions'
            req = new ListUserPurchases("user");
            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 ListUserPurchases request</summary>
        /// <param name="request">Request to be sent</param>
        /// <returns>Response from the API</returns>
        public async Task <IEnumerable <Purchase> > SendAsync(ListUserPurchases 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 <Purchase> ParseResponse(string json, ListUserPurchases request)
 {
     return(JsonConvert.DeserializeObject <Purchase[]>(json));
 }
        /// <summary>Send the ListUserPurchases request</summary>
        /// <param name="request">Request to be sent</param>
        /// <returns>Response from the API</returns>
        public IEnumerable <Purchase> Send(ListUserPurchases request)
        {
            var json = SendRequest(request);

            return(ParseResponse(json, request));
        }