using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using ZuluFeedsSampleApp.Model;

namespace ZuluFeedsSampleApp.Util
{
    public class TickMessageUtil
    {
        public static TickMessage getTick(String line)
        {
            if (line.Contains("data: "))
            {
                try
                {
                    String tickMessageAsString = line.Replace("data: ", "");
                    TickMessage tick = JsonConvert.DeserializeObject<TickMessage>(tickMessageAsString);
                    return tick;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception processing Tick", e.Message);
                    return null;
                }
            }
            return null;
        }
    }
}
