public static DSS1_RetailerDriverStockOptimisation.ExternalStructs.XPackML.Results GetAnomaliesOnHits(int?hits, DSS1_RetailerDriverStockOptimisation.ExternalStructs.XPackML.RecordRequest q)
        {
            System.Func <string> getUrl = () =>
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
                return("/.ml-anomalies-custom-obapi_hm_resp_hits_per_service/_search?size=" + hits.GetValueOrDefault(0));
            };
            var _operationRelativeUrl = getUrl.Invoke().Trim();

            if (_operationRelativeUrl?.StartsWith("/") == true && BaseUrl?.EndsWith("/") == true)
            {
                _operationRelativeUrl = _operationRelativeUrl.TrimStart('/');
            }
            var _targetUrl = BaseUrl + _operationRelativeUrl;
            var _options   = new RestServiceConsumptionOptions
            {
                Url             = _targetUrl,
                Verb            = RestHTTPVerb.POST,
                SecurityType    = RestSecurityType.BasicAuth,
                UserName        = "******",
                Password        = "******",
                ExtraHeaderData = new System.Collections.Generic.Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
                {
                },
                LogAccess        = false,
                IsCachingEnabled = false,
                ApiName          = "XPackML",
                Operation        = "GetAnomaliesOnHits",
                PostType         = PostType.JSON,
                Data             = q, FormData = new Dictionary <string, object> {
                    { "q", q }
                }
            };
            Func <ServiceConsumptionContainer, DSS1_RetailerDriverStockOptimisation.ExternalStructs.XPackML.Results> _invocation = (_httpResponse) =>
            {
                var _returnedItem = RestServiceConsumer.Consume <DSS1_RetailerDriverStockOptimisation.ExternalStructs.XPackML.Results>(_options, _httpResponse);
                return(zAppDev.DotNet.Framework.Utilities.Common.SafeCast <DSS1_RetailerDriverStockOptimisation.ExternalStructs.XPackML.Results>(_returnedItem));
            };
            var _consumer = new ServiceConsumer <DSS1_RetailerDriverStockOptimisation.ExternalStructs.XPackML.Results>(_invocation);

            return(_consumer.Invoke(_options));
        }