using EVCB_OCPP.Packet.Features;
using EVCB_OCPP.Packet.Messages.SubTypes;
using Newtonsoft.Json;
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 SignedUpdateFirmwareRequest : IRequest
    {
        public SignedUpdateFirmwareRequest()
        {
            Action = Actions.SignedUpdateFirmware.ToString();
        }

        /// <summary>
        /// This specifies how many times Charge Point must try to download the
        ///firmware 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>
        /// The Id of this request
        /// </summary>
        [Required]
        public int requestId { set; get; }

        /// <summary>
        /// Specifies the firmware to be updated on the Charge Point.
        /// </summary>
        [Required]
        public FirmwareType firmware { 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);
        }
    }
}