public async Task <AccountDetailsResponse> GetAccountDetailsAsync(GetAccountDetailsRequest request) { try { int reTryAttempts = 0; bool isRequestSuccess = false; do { client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var builder = new UriBuilder(new Uri(string.Format(AccountDetailsAsyncUrl, CustomerId, request.RequestId))); HttpResponseMessage response = await client.GetAsync(builder.Uri.AbsoluteUri); var res = await response.Content.ReadAsAsync <AccountDetailsResponse>(); if (response.StatusCode == HttpStatusCode.OK) { return(res); } reTryAttempts += 1; Thread.Sleep(10000); }while (!isRequestSuccess && reTryAttempts < 30); return(new AccountDetailsResponse()); } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task <AccountDetailsResponse> GetAccountDetails(GetAccountDetailsRequest request) { try { var myContent = JsonConvert.SerializeObject(request); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var builder = new UriBuilder(new Uri(string.Format(AccountDetailsUrl, CustomerId))); HttpRequestMessage requests = new HttpRequestMessage(HttpMethod.Post, builder.Uri); requests.Content = new StringContent(myContent, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.SendAsync(requests); if (response.StatusCode == HttpStatusCode.Accepted) { var result = await GetAccountDetailsAsync(request); return(await response.Content.ReadAsAsync <AccountDetailsResponse>()); } return(await response.Content.ReadAsAsync <AccountDetailsResponse>()); } catch (Exception e) { Console.WriteLine(e); throw; } }
public virtual Task <GetAccountDetailsResponse> GetAsync(GetAccountDetailsRequest request) => Client.SendAsync <GetAccountDetailsResponse>(request);