using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace FogbugzWrapper
{
	[XmlRoot(ElementName = "event")]
	public class Event
	{

		[XmlElement(ElementName = "ixBugEvent")]
		public List<int> IxBugEvent { get; set; }

		[XmlElement(ElementName = "evt")]
		public int Evt { get; set; }

		[XmlElement(ElementName = "sVerb")]
		public string SVerb { get; set; }

		[XmlElement(ElementName = "ixPerson")]
		public int IxPerson { get; set; }

		[XmlElement(ElementName = "ixPersonAssignedTo")]
		public int IxPersonAssignedTo { get; set; }

		[XmlElement(ElementName = "dt")]
		public DateTime Dt { get; set; }

		[XmlElement(ElementName = "s")]
		public object S { get; set; }

		[XmlElement(ElementName = "fEmail")]
		public bool FEmail { get; set; }

		[XmlElement(ElementName = "fHTML")]
		public bool FHTML { get; set; }

		[XmlElement(ElementName = "fExternal")]
		public bool FExternal { get; set; }

		[XmlElement(ElementName = "sChanges")]
		public object SChanges { get; set; }

		[XmlElement(ElementName = "sFormat")]
		public object SFormat { get; set; }

		[XmlElement(ElementName = "rgAttachments")]
		public object RgAttachments { get; set; }

		[XmlElement(ElementName = "evtDescription")]
		public string EvtDescription { get; set; }

		[XmlElement(ElementName = "bEmail")]
		public bool BEmail { get; set; }

		[XmlElement(ElementName = "bExternal")]
		public bool BExternal { get; set; }

		[XmlElement(ElementName = "sPerson")]
		public string SPerson { get; set; }

		[XmlElement(ElementName = "sHtml")]
		public object SHtml { get; set; }

		[XmlAttribute(AttributeName = "ixBug")]
		public int IxBug { get; set; }

		[XmlText]
		public string Text { get; set; }
	}

	[XmlRoot(ElementName = "events")]
	public class Events
	{

		[XmlElement(ElementName = "event")]
		public List<Event> Event { get; set; }
	}

	[XmlRoot(ElementName = "case")]
	public class Case
	{
		[XmlElement(ElementName = "ixBug")]
		public List<int> IxBug { get; set; }
		public int BugIdx
		{
			get => IxBug[0];
		}

		[XmlElement(ElementName = "ixProject")]
		public int IxProject { get; set; }

		[XmlElement(ElementName = "fOpen")]
		public bool FOpen { get; set; }

		[XmlElement(ElementName = "sTitle")]
		public string STitle { get; set; }

		[XmlElement(ElementName = "sProject")]
		public string SProject { get; set; }

		[XmlElement(ElementName = "sArea")]
		public string SArea { get; set; }

		[XmlElement(ElementName = "sStatus")]
		public string SStatus { get; set; }

		[XmlElement(ElementName = "dtLastUpdated")]
		public DateTime DtLastUpdated { get; set; }
		
		[XmlElement(ElementName = "events")]
		public Events Events { get; set; }

		[XmlAttribute(AttributeName = "operations")]
		public string Operations { get; set; }

		[XmlText]
		public string Text { get; set; }
		public Case() { }
		public Case(Case copy)
        {
			IxBug = copy.IxBug;
			IxProject = copy.IxProject;
			FOpen = copy.FOpen;
			STitle = copy.STitle;
			SProject = copy.SProject;
			SArea = copy.SArea;
			SStatus = copy.SStatus;
			DtLastUpdated = copy.DtLastUpdated;
			Operations = copy.Operations;
			Text = copy.Text;
        }
	}

	[XmlRoot(ElementName = "cases")]
	public class Cases
	{

		[XmlElement(ElementName = "case")]
		public List<Case> Case { get; set; }

		[XmlAttribute(AttributeName = "count")]
		public int Count { get; set; }

		[XmlAttribute(AttributeName = "totalHits")]
		public int TotalHits { get; set; }

		[XmlText]
		public string Text { get; set; }
	}

	[XmlRoot(ElementName = "response")]
	public class CasesResponse
	{

		[XmlElement(ElementName = "description")]
		public string Description { get; set; }

		[XmlElement(ElementName = "cases")]
		public Cases Cases { get; set; }
	}


}
