public async Task <List <Response> > DetectAnomalies()
        {
            List <TransferenciaEntity> transferencias = await table.RetrieveAllTransferenciasAsync();

            AnomalyRequest request = new AnomalyRequest("daily", transferencias);

            var json = JsonConvert.SerializeObject(request);

            AnomalyResponse anomalies = api.DetectAnomaliesBatch(json);
            List <Response> responses = new List <Response>();

            for (int i = 0; i < request.series.Count; ++i)
            {
                var serie = request.series[i];
                responses.Add(new Response(serie.timestamp, serie.value, anomalies, i));
            }

            return(responses);
        }
        public AnomalyResponse DetectAnomaliesBatch(string requestData)
        {
            System.Console.WriteLine("Detecting anomalies as a batch");
            AnomalyResponse response = new AnomalyResponse();
            //construct the request
            var result = Request(
                endpoint,
                batchDetectionUrl,
                subscriptionKey,
                requestData).Result;

            //deserialize the JSON object, and display it
            dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(result);

            System.Console.WriteLine(jsonObj);

            if (jsonObj["code"] != null)
            {
                System.Console.WriteLine($"Detection failed. ErrorCode:{jsonObj["code"]}, ErrorMessage:{jsonObj["message"]}");
            }
            else
            {
                //Find and display the positions of anomalies in the data set
                response.isAnomaly      = jsonObj["isAnomaly"].ToObject <List <bool> >();
                response.expectedValues = jsonObj["expectedValues"].ToObject <List <string> >();

                System.Console.WriteLine("\nAnomalies detected in the following data positions:");
                for (var i = 0; i < response.isAnomaly.Count; i++)
                {
                    if (response.isAnomaly[i])
                    {
                        System.Console.Write(i + ", ");
                    }
                }
                return(response);
            }
            return(response);
        }