/// <summary>
		/// Update the custom field values for a ticket. Please note all custom fields for the ticket must be sent through with
		/// their values.
		/// </summary>
		public TicketCustomFields UpdateTicketCustomFields(int ticketId, TicketCustomFields customFields)
		{
			string apiMethod = String.Format("/Tickets/TicketCustomField/{0}", ticketId);

			StringBuilder sb = new StringBuilder();
			foreach(TicketCustomFieldGroup group in customFields.FieldGroups)
			{
				foreach(TicketCustomField field in group.Fields)
				{
					if(!String.IsNullOrEmpty(sb.ToString()))
					{
						sb.Append("&");
					}

					sb.AppendFormat("{0}={1}", field.Name, HttpUtility.UrlEncode((field.FieldContent ?? "")));
				}
			}

			return Connector.ExecutePost<TicketCustomFields>(apiMethod, sb.ToString());
		}
        public void Setup()
        {
            _kayakoApiRequest = new Mock<IKayakoApiRequest>();

            _ticketController = new TicketController(_kayakoApiRequest.Object);

            _responseTicketCollection = new TicketCollection
                {
                    new Ticket()
                };

            _createTicketRequestRequiredFields = new TicketRequest
                {
                    Subject = "Subject",
                    FullName = "Fullname",
                    Email = "*****@*****.**",
                    Contents = "Contents",
                    DepartmentId = 1,
                    TicketStatusId = 2,
                    TicketPriorityId = 3,
                    TicketTypeId = 4
                };

            _createTicketRequiredFieldsParameters = "subject=Subject&fullname=Fullname&[email protected]&contents=Contents&departmentid=1&ticketstatusid=2&ticketpriorityid=3&tickettypeid=4";

            _responseTicketCustomFields = new TicketCustomFields
                {
                    FieldGroups = new List<TicketCustomFieldGroup>
                        {
                            new TicketCustomFieldGroup
                                {
                                    Id = 1,
                                    Title = "Title",
                                    Fields = new[]
                                        {
                                            new TicketCustomField
                                                {
                                                    Type = TicketCustomFieldType.Text,
                                                    Name = "FieldName1",
                                                    FieldContent = "content1"
                                                },
                                            new TicketCustomField
                                                {
                                                    Type = TicketCustomFieldType.Text,
                                                    Name = "FieldName2",
                                                    FieldContent = "content2"
                                                }
                                        }
                                }
                        }
                };
        }
        public void TicketCustomFieldCollectionDeserialization()
        {
            var ticketcustomFields = new TicketCustomFields
                {
                    FieldGroups = new List<TicketCustomFieldGroup>
                        {
                            new TicketCustomFieldGroup
                                {
                                    Id = 4,
                                    Title = "Test Ticket",
                                    Fields = new []
                                        {
                                            new TicketCustomField
                                            {
                                                Id = 2,
                                                Type = TicketCustomFieldType.Text,
                                                Name = "ab32ds122",
                                                Title = "Test",
                                                FieldContent = "Test Plaintext Field"
                                            },
                                            new TicketCustomField
                                            {
                                                Id = 3,
                                                Type = TicketCustomFieldType.LinkedSelectFields,
                                                Name = "fd923nds2",
                                                Title = "Linked Select",
                                                FieldContent = "Product > Fusion"
                                            },
                                            new TicketCustomField
                                            {
                                                Id = 4,
                                                Type = TicketCustomFieldType.MultiSelect,
                                                Name = "mcz923nxa",
                                                Title = "Multiple",
                                                FieldContent = "Value1, Value2"
                                            },
                                            new TicketCustomField
                                            {
                                                Id = 5,
                                                Type = TicketCustomFieldType.Date,
                                                Name = "z13nc8923",
                                                Title = "Date",
                                                FieldContent = "05/24/2011"
                                            },
                                            new TicketCustomField
                                            {
                                                Id = 6,
                                                Type = TicketCustomFieldType.File,
                                                FileName = "report.txt",
                                                Name = "mds923nx92",
                                                Title = "File",
                                                FieldContent = "VTFkSlJsUXRNVE01TURvZ1EzVnpkRzl0SUVacFpXeGtjeUJwYmlCVWFXTnJaWFFnVm1sbGQzTUtDbE5YU1VaVUxURXpPVEU2SUZCMVlteHBZeTlRY21sMllYUmxJRlpwYzJsaWFXeHBkSGtnVkc5bloyeGxJR2x1SUZWelpYSXZWWE5sY2lCUGNtZGhibWw2WVhScGIyNGdRM1Z6ZEc5dElFWnBaV3hrSUVkeWIzVndjd29L"
                                            }
                                        }
                                }
                        }
                };

            var expectedTicketCustomFields = XmlDataUtility.ReadFromFile<TicketCustomFields>("TestData/TicketCustomFields.xml");

            AssertUtility.ObjectsEqual(expectedTicketCustomFields, ticketcustomFields);
        }