protected virtual string GenerateRequestBody(ReplicateDatabaseRequest request)
        {
            Ensure.That(request, "request").IsNotNull();
            Ensure.That(request.Source, "request.Source").IsNotNullOrWhiteSpace();
            Ensure.That(request.Target, "request.Target").IsNotNullOrWhiteSpace();

            var tmp = new Dictionary<string, object>
            {
                { KeyNames.Source, request.Source },
                { KeyNames.Target, request.Target }
            };

            if (request.HasDocIds())
                tmp.Add(KeyNames.DocIds, request.DocIds);

            if (!string.IsNullOrWhiteSpace(request.Proxy))
                tmp.Add(KeyNames.Proxy, request.Proxy);

            if (request.CreateTarget.HasValue)
                tmp.Add(KeyNames.CreateTarget, request.CreateTarget);

            if (request.Continuous.HasValue)
                tmp.Add(KeyNames.Continuous, request.Continuous.Value);

            if (!string.IsNullOrWhiteSpace(request.Filter))
                tmp.Add(KeyNames.Filter, request.Filter);

            if (request.HasQueryParams())
                tmp.Add(KeyNames.QueryParams, request.QueryParams);

            return Serializer.Serialize(tmp);
        }
        public virtual HttpRequest Create(ReplicateDatabaseRequest request)
        {
            Ensure.That(request, "request").IsNotNull();

            return new HttpRequest(HttpMethod.Put, GenerateRelativeUrl(request))
                .SetRequestTypeHeader(request.GetType())
                .SetJsonContent(GenerateRequestBody(request));
        }
 protected virtual string GenerateRelativeUrl(ReplicateDatabaseRequest request)
 {
     return "/_replicator/" + new UrlSegment(request.Id);
 }