public virtual HttpRequest Create(GetDocumentRequest request) { Ensure.That(request, "request").IsNotNull(); return new HttpRequest(HttpMethod.Get, GenerateRelativeUrl(request)) .SetRequestTypeHeader(request.GetType()) .SetIfMatchHeader(request.Rev); }
protected virtual string GenerateRelativeUrl(GetDocumentRequest request) { var urlParams = new UrlParams(); urlParams.AddIfNotNullOrWhiteSpace("rev", request.Rev); urlParams.AddIfTrue("conflicts", request.Conflicts); return string.Format("/{0}{1}", new UrlSegment(request.Id), new QueryString(urlParams)); }
protected virtual HttpRequest CreateHttpRequest(GetDocumentRequest request) { return GetDocumentHttpRequestFactory.Create(request); }
public virtual async Task<DocumentResponse> GetAsync(GetDocumentRequest request) { Ensure.That(request, "request").IsNotNull(); using (var httpRequest = CreateHttpRequest(request)) { using (var res = await SendAsync(httpRequest).ForAwait()) { return ProcessDocumentResponse(res); } } }