public IActionResult PostRank([FromBody] RankCategories rankCategories)
        {
            RankRequest  request = CreateRankRequest(rankCategories);
            RankResponse response;

            try
            {
                response = personalizerClient?.Rank(request);
                return(Ok(response));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        private RankRequest CreateRankRequest(RankCategories rankCategories)
        {
            string timeOfDay = DateTime.Now.Hour.ToString();
            string dayOfWeek = DateTime.Now.DayOfWeek.ToString();
            string userAgent = Request.Headers["User-Agent"].ToString();
            Regex  osRegex   = new Regex(@"\(([^\)]*)\)");
            string osInfo    = osRegex.Match(userAgent).Groups[1].Value;

            IList <object> currentContext = new List <object>()
            {
                new { time = timeOfDay },
                new { weekday = dayOfWeek },
                new { userOS = osInfo }
            };

            IList <RankableAction> actions = rankCategories.Categories.Select(category =>
            {
                return(new RankableAction(category, featureMap.GetValueOrDefault(category, new List <object>())));
            }).ToList();

            return(new RankRequest(actions, currentContext));
        }