using System;
using System.Collections.Generic;
using CareFusion.Mosaic.Interfaces.Converters;
using CareFusion.Mosaic.Interfaces.Types.Packs;

namespace CareFusion.Mosaic.Interfaces.Messages.Input
{
    /// <summary>
    /// Class which implements the InfeedInputRequest Mosaic message.
    /// This request is used to initiate infeed input of one ore more packs.
    /// </summary>
    public class InfeedInputRequest : MosaicMessage, ICloneable
    {
        #region Members

        /// <summary>
        /// Holds the list of packs that are waiting for input.
        /// </summary>
        private readonly List<RobotPack> _packList = new List<RobotPack>();

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the infeed to use for the infeed input.
        /// </summary>
        public int InfeedNumber { get; set; }

        /// <summary>
        /// Gets or sets an optional informational external order number.
        /// </summary>
        public string ExternalOrderNumber { get; set; }

        /// <summary>
        /// Gets or sets the flag whether the input should belong to a delivery input.
        /// </summary>
        public bool IsDeliveryInput { get; set; }

        /// <summary>
        /// Gets or sets the flag whether the picking indicator should be set for the articles of the infeed input.
        /// </summary>
        public bool SetPickingIndicator { get; set; }

        /// <summary>
        /// Gets the list of packs that are waiting for input.
        /// </summary>
        public List<RobotPack> Packs => _packList;

        #endregion

        /// <summary>
        /// Initializes a new instance of the <see cref="InfeedInputRequest"/> class.
        /// </summary>
        public InfeedInputRequest()
            : base(MessageType.InfeedInputRequest)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InfeedInputRequest"/> class.
        /// </summary>
        /// <param name="converterStream">The converter stream which created the request.</param>
        public InfeedInputRequest(IConverterStream converterStream)
            : base(MessageType.InfeedInputRequest, converterStream)
        {
        }

        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public object Clone()
        {
            var clone = new InfeedInputRequest(this.ConverterStream);
            clone._packList.AddRange(_packList);
            clone.ConverterData = this.ConverterData;
            clone.Destination = this.Destination;
            clone.ID = this.ID;
            clone.InfeedNumber = this.InfeedNumber;
            clone.IsDeliveryInput = this.IsDeliveryInput;
            clone.SetPickingIndicator = this.SetPickingIndicator;
            clone.Source = this.Source;
            clone.TenantID = this.TenantID;
            clone.ExternalOrderNumber = this.ExternalOrderNumber;
            return clone;
        }
    }
}
