Example #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="purchase"></param>
 /// <returns></returns>
 /// <exception cref="DataConflictException">When product definition has changed on server</exception>
 public async Task <PurchasedItem> AddPuchase(PurchaseOrder purchase)
 {
     return(await HttpExtension.AskRetryOnHttpStatusFail(
                async() => {
         try
         {
             return await _connectionService.PostJsonAuthorizedAsync <PurchaseOrder, PurchasedItem>(purchase, u => u.Shop.User);
         }
         catch (HttpStatusCodeException ex) when(ex.Status == HttpStatusCode.Conflict)
         {
             var proposal = JsonConvert.DeserializeObject <PurchaseOrder>(ex.Content);
             throw new DataConflictException(proposal);
         }
     }));
 }
        public async Task <Urls> GetUrls()
        {
            if (_result != null)
            {
                return(_result);
            }

            var client = CreateHttpClient(x => x);

            _result = await HttpExtension.AskRetryOnHttpStatusFail(
                async() =>
            {
                var response = await client.GetAsync(Config.ApiConfigUrl);
                return(await response.ParseJsonResponseBody <Urls>());
            });

            return(_result);
        }
Example #3
0
 public async Task <List <Product> > GetProducts()
 {
     return(await HttpExtension.AskRetryOnHttpStatusFail(
                () => _connectionService.GetJsonAsync <List <Product> >(urls => urls.Shop.Products)
                ));
 }
Example #4
0
 public async Task <AccountInfo> GetAccountInfo()
 {
     return(await HttpExtension.AskRetryOnHttpStatusFail(
                () => _connectionService.GetJsonAuthorizedAsync <AccountInfo>(u => u.Shop.User, cache: false)
                ));
 }