예제 #1
0
        public Uri GetTerminalEndpoint(string transactionId)
        {
            var ub = new UriBuilder(this._endpoints.Terminal);
            var qb = new HttpQueryBuilder();

            qb.Add("merchantId", this._merchantId);
            qb.Add("transactionId", transactionId);
            ub.Query = qb.ToString();
            return(ub.Uri);
        }
예제 #2
0
        public Uri GetUri <T>(Uri endpoint, IDictionary <string, string> arguments, T options = default(T))
        {
            var ub = new UriBuilder(endpoint);
            var qb = new HttpQueryBuilder();

            foreach (var param in arguments)
            {
                qb.Add(param.Key, param.Value);
            }
            if (options != null)
            {
                var properties = typeof(T).GetRuntimeProperties().Where(p => p.CanRead)
                                 .Where(p => (p.PropertyType != typeof(bool) && p.GetValue(options) != null) || (p.PropertyType == typeof(bool) && (bool)p.GetValue(options)))
                                 .Select(p => new KeyValuePair <string, string>(String.Format("{0}{1}", p.Name.Substring(0, 1).ToLowerInvariant(), p.Name.Substring(1)), p.GetValue(options).ToString()))
                                 .ToList();
                foreach (var kvp in properties)
                {
                    qb.Add(kvp.Key, kvp.Value);
                }
            }
            ub.Query = qb.ToString();
            return(ub.Uri);
        }