<commit_before>﻿// -----------------------------------------------------------------------
// <copyright file="RestRequest.cs">
// Copyright (c) 2015 <NAME>. All rights reserved.
// License: Apache License 2.0
// Contacts: http://andrey.moveax.com <EMAIL>
// </copyright>
// -----------------------------------------------------------------------

namespace RestArt.Requests
{
    using System.Collections.Generic;
    using RestArt.Convertors;

    public class RestRequest : IRestRequest
    {
        private static readonly ObjectConvertor _objectConvertor = new ObjectConvertor();

        public HttpVerb Verb { get; }

        public string Command { get; }

        public IDictionary<string, string> Headers { get; }

        public IDictionary<string, object> Parameters { get; }

        public RestRequest(HttpVerb verb, string command, IDictionary<string, string> headers, IDictionary<string, object> parameters)
        {
            this.Verb = verb;
            this.Command = command;
            this.Headers = headers;
            this.Parameters = parameters;
        }

        public RestRequest(HttpVerb verb, string command, object headers, object parameters)
        {
            this.Verb = verb;
            this.Command = command;
            this.Headers = RestRequest._objectConvertor.ToStringDictionary(headers);
            this.Parameters = RestRequest._objectConvertor.ToObjectDictionary(parameters);
        }
    }
}<commit_msg>Improved support for headers and parameters in request.<commit_after>﻿// -----------------------------------------------------------------------
// <copyright file="RestRequest.cs">
// Copyright (c) 2015 <NAME>. All rights reserved.
// License: Apache License 2.0
// Contacts: http://andrey.moveax.com <EMAIL>
// </copyright>
// -----------------------------------------------------------------------

namespace RestArt.Requests
{
    using System.Collections.Generic;
    using RestArt.Convertors;

    public class RestRequest : IRestRequest
    {
        private static readonly ObjectConvertor _objectConvertor = new ObjectConvertor();

        public HttpVerb Verb { get; }

        public string Command { get; }

        public IDictionary<string, string> Headers { get; }

        public IDictionary<string, object> Parameters { get; }

        public RestRequest(HttpVerb verb, string command, IDictionary<string, string> headers, IDictionary<string, object> parameters)
        {
            this.Verb = verb;
            this.Command = command;
            this.Headers = headers;
            this.Parameters = parameters;
        }

        public RestRequest(HttpVerb verb, string command, object headers, object parameters)
        {
            this.Verb = verb;
            this.Command = command;

            this.Headers = headers.GetType() == typeof(IDictionary<string, string>) ?
                (IDictionary<string, string>)headers :
                RestRequest._objectConvertor.ToStringDictionary(headers);

            this.Parameters = parameters.GetType() == typeof(IDictionary<string, object>) ?
                (IDictionary<string, object>)parameters : 
                RestRequest._objectConvertor.ToObjectDictionary(parameters);
        }
    }
}
{'fraction_non_alphanumeric': 0.17741437827830916, 'fraction_numerical': 0.0037025609379821045, 'mean_word_length': 1.8843416370106763, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3002712', 'n_tokens_mistral': 775, 'n_tokens_neox': 743, 'n_words': 195}