using EVCB_OCPP.Packet.Features;
using EVCB_OCPP.Packet.Messages.SubTypes;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EVCB_OCPP.Packet.Messages.Security
{
    public class GetLogRequest:IRequest
    {
        public GetLogRequest()
        {
            Action = Actions.GetLog.ToString();
        }

        /// <summary>
        /// This contains the type of log file that the Charge Point should send.
        /// </summary>
        [Required]
        [JsonConverter(typeof(StringEnumConverter))]
        public LogEnumType logType { set; get; }

        /// <summary>
        /// The Id of this request
        /// </summary>
        [Required]
        public int requestId { set; get; }

        /// <summary>
        /// This specifies how many times the Charge Point must try to upload the
        /// log before giving up.If this field is not present, it is left to Charge Point to decide
        /// how many times it wants to retry
        /// </summary>
        public int retries { set; get; }

        /// <summary>
        /// The interval in seconds after which a retry may be attempted. If this
        ///field is not present, it is left to Charge Point to decide how long to wait between
        ///attempts.
        /// </summary>
        public int retryInterval { set; get; }

        /// <summary>
        /// This field specifies the requested log and the location to which the log
        ///should be sent.
        /// </summary>
        [Required]
        public LogParametersType log { set; get; }

        [JsonIgnore]
        public string Action { set; get; }

        public bool TransactionRelated()
        {
            return false;
        }

        public bool Validate()
        {
            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
        }
    }
}
