All Downloads are FREE. Search and download functionalities are using the official Maven repository.

csharp-functions.WebRequestPathBuilder.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{>partial_header}}
using System.Collections.Generic;

namespace {{packageName}}.Client
{
    /// 
    /// A URI builder
    /// 
    class WebRequestPathBuilder
    {
            private string _baseUrl;
            private string _path;
            private string _query = "?";
            public WebRequestPathBuilder(string baseUrl, string path)
            {
                _baseUrl = baseUrl;
                _path = path;
            }

            public void AddPathParameters(Dictionary parameters)
            {
                foreach (var parameter in parameters)
                {
                    _path = _path.Replace("{" + parameter.Key + "}", parameter.Value);
                }
            }

            public void AddQueryParameters(Multimap parameters)
            {
                foreach (var parameter in parameters)
                {
                    foreach (var value in parameter.Value)
                    {
                        _query = _query + parameter.Key + "=" + value + "&";
                    }
                }
            }

            public string GetFullUri()
            {
                return _baseUrl + _path + _query.Substring(0, _query.Length - 1);
            }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy