private HttpContent GetContent(SerializerResolver serializer)
        {
            switch (BodyType)
            {
            case BodyType.Encoded:
                return(new FormUrlEncodedContent(ParameterUtils.GetParameter <FormParameter>(this, RequestCulture)));

            case BodyType.Serialized:
                return(serializer.Resolve(GetType(), DataDirection.Out).Serialize(this));

            case BodyType.SerializedProperty:
                var body = serializer.Resolve(GetType(), DataDirection.Out).Serialize(ParameterUtils.GetSingleParameterObject <RequestBody>(this));
                return(body);

            case BodyType.Custom:
                return(BodyContent);

            default:
                //todo custom exception - there should have been a datatype specified
                throw new ArgumentOutOfRangeException();
            }
        }
        /// <summary>
        /// Create a <see cref="HttpResponseMessage"/> for this <see cref="ApiRequest"/>, which can then be modified manually or overriden by <see cref="ApiClient.SetupRequest"/>
        /// </summary>
        /// <remarks>
        /// This validates the <see cref="Path"/> and <see cref="RequireAuth"/> properties, throwing a <see cref="ClientValidationException"/> if it's unsatisfied with the constraints
        /// </remarks>
        public HttpRequestMessage Build(SerializerResolver serializer)
        {
            if (!Path.StartsWith("http") && !Path.StartsWith("//"))
            {
                throw new HttpRequestException("The request path is invalid (it must start with http or https)");
            }

            var request = new HttpRequestMessage
            {
                RequestUri = new Uri(FullUrl)
            };

            // generic setup
            switch (Method)
            {
            case Methods.Get:
                request.Method = HttpMethod.Get;
                break;

            case Methods.Post:
                request.Method  = HttpMethod.Post;
                request.Content = GetContent(serializer);
                break;

            case Methods.Put:
                request.Method  = HttpMethod.Put;
                request.Content = GetContent(serializer);
                break;

            case Methods.Patch:
#if NETSTANDARD2_0
                // .NET Standard 2.0 doesn't have a PATCH method...
                request.Method = new HttpMethod("PATCH");
#else
                request.Method = HttpMethod.Patch;
#endif
                request.Content = GetContent(serializer);
                break;

            case Methods.Delete:
                request.Method  = HttpMethod.Delete;
                request.Content = GetContent(serializer);
                break;

            case Methods.Head:
                request.Method = HttpMethod.Head;
                break;

            case Methods.Trace:
                request.Method = HttpMethod.Trace;
                break;

            default:
                throw new NotImplementedException();
            }

            if (CustomHeaderCollectionCreated)
            {
                foreach (var header in Headers)
                {
                    request.Headers.Add(header.Key, header.Value);
                }
            }

            if (!request.Headers.Contains("Accept"))
            {
                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(serializer.Resolve(GetType(), DataDirection.In).ContentType));
            }

            return(request);
        }