public void WhenTheUserGetsThePost(int id) { _settings.Request.AddUrlSegment("id", id.ToString()); _response = _restClientHelper.GetAsync <Posts>(_settings.Request) .GetAwaiter().GetResult(); }
public async Task <ServiceResponse <LoginData> > GetUserAsync() { var client = new RestClientHelper(Constants.LoginServerUrl); var result = await client.GetAsync <LoginData>("/user/" + Constants.UserId); return(result); }
public async Task <int> GetHeightAsync(string element, int?heightOfLadderInRungs = null, TimeSpan?timeout = null, CancellationToken cancellationToken = new CancellationToken()) { DateTime whenAddedUtc; int topOfLadder = heightOfLadderInRungs ?? MaxLadderHeight; bool cacheIndicatesTopOfLadder = CacheOfElementsAtTopOfLadder.TryGetValue(element, out whenAddedUtc); if (cacheIndicatesTopOfLadder && DateTime.UtcNow - whenAddedUtc < MinimumCacheFreshnessRequired) { return(topOfLadder); } int shard = GetShardIndex(element); RemoteHost host = ShardToHostMapping.FindMemberResponsible(shard.ToString()); int height = await RestClientHelper.GetAsync <int>(host.Uri, ElementsPath + Uri.EscapeUriString(element), cancellationToken : cancellationToken, uriParameters : (!heightOfLadderInRungs.HasValue)?null : new[] { new KeyValuePair <string, string>("heightOfLadderInRungs", heightOfLadderInRungs.Value.ToString()) }); if (height < topOfLadder && cacheIndicatesTopOfLadder) { CacheOfElementsAtTopOfLadder.Remove(element); } else if (height == topOfLadder) { CacheOfElementsAtTopOfLadder[element] = DateTime.UtcNow; } return(height); }