// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//  
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
//     
//	   Copyright (c) 2018 Citrix ShareFile. All rights reserved.
// </auto-generated>
// ------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Net;

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ShareFile.Api.Client.Extensions;
using ShareFile.Api.Client.Exceptions;

namespace ShareFile.Api.Client.Models 
{
	/// <summary>
	/// Represents a participant in a Workflow.
	/// </summary>
	public class WorkflowParticipant : ODataObject 
	{
		public int? Ordinal { get; set; }
		public SafeEnum<WorkflowRole> Role { get; set; }
		public Contact Contact { get; set; }
		public SafeEnum<WorkflowStatus> Status { get; set; }
		public DateTime? LastStatusUpdate { get; set; }

		public override void Copy(ODataObject source, JsonSerializer serializer)
		{
			if(source == null || serializer == null) return;
			base.Copy(source, serializer);

			var typedSource = source as WorkflowParticipant;
			if(typedSource != null)
			{
				Ordinal = typedSource.Ordinal;
				Role = typedSource.Role;
				Contact = typedSource.Contact;
				Status = typedSource.Status;
				LastStatusUpdate = typedSource.LastStatusUpdate;
			}
			else
			{
				JToken token;
				if(source.TryGetProperty("Ordinal", out token) && token.Type != JTokenType.Null)
				{
					Ordinal = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?));
				}
				if(source.TryGetProperty("Role", out token) && token.Type != JTokenType.Null)
				{
					Role = (SafeEnum<WorkflowRole>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<WorkflowRole>));
				}
				if(source.TryGetProperty("Contact", out token) && token.Type != JTokenType.Null)
				{
					Contact = (Contact)serializer.Deserialize(token.CreateReader(), typeof(Contact));
				}
				if(source.TryGetProperty("Status", out token) && token.Type != JTokenType.Null)
				{
					Status = (SafeEnum<WorkflowStatus>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<WorkflowStatus>));
				}
				if(source.TryGetProperty("LastStatusUpdate", out token) && token.Type != JTokenType.Null)
				{
					LastStatusUpdate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?));
				}
			}
		}
	}
}