internal static async Task <T> PostToService <T>(this ICexClient This, string servicePath, Func <IEnumerable <KeyValuePair <string, string> > > paramFactory, Func <dynamic, T> resultFactory, CancellationToken?cancelToken = null)
        {
            long nonce;
            var  signature = This.Credentials.NewSignature(out nonce);
            var  content   = new FormUrlEncodedContent(
                new[]
            {
                NewRequestParam(This, Constants.ApiParamKey, This.Credentials.ApiKey),
                NewRequestParam(This, Constants.ApiParamSignature, signature),
                NewRequestParam(This, Constants.ApiParamNonce, Convert.ToString(nonce))
            }
                .Concat(paramFactory())
                );

            var uri = This.GetApiUri(servicePath);

            using (var client = This.NewHttpClient())
            {
                using (var response = await(cancelToken.HasValue ? client.PostAsync(uri, content, cancelToken.Value) : client.PostAsync(uri, content)))
                {
                    var body = await response.Content.ReadAsStringAsync();

                    dynamic json = SimpleJson.DeserializeObject(body);

                    ExceptionOracle.ThrowIfError(response, json);
                    return(resultFactory(json));
                }
            }
        }
        internal static async Task <T> GetFromService <T>(this ICexClient This, string servicePath, Func <dynamic, T> resultFactory, CancellationToken?cancelToken = null)
        {
            var uri = This.GetApiUri(servicePath);

            using (var client = This.NewHttpClient())
            {
                using (var response = await(cancelToken.HasValue ? client.GetAsync(uri, cancelToken.Value) : client.GetAsync(uri)))
                {
                    var body = await response.Content.ReadAsStringAsync();

                    dynamic json = SimpleJson.DeserializeObject(body);

                    ExceptionOracle.ThrowIfError(response, json);
                    return(resultFactory(json));
                }
            }
        }