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

namespace EVCB_OCPP.Packet.Messages.Core
{
    public class StartTransactionRequest : IRequest
    {

        public StartTransactionRequest()
        {
            Action = Actions.StartTransaction.ToString();
        }

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

        /// <summary>
        /// 充電槍號(開始為1)
        /// </summary>
        [Required]
        public int connectorId { set; get; }
        /// <summary>
        /// Authorization Id
        /// </summary>
        [Required(AllowEmptyStrings = true)]
        public string idTag { set; get; }
        /// <summary>
        /// 充電開始的電表讀數
        /// </summary>
        [Required]
        public int meterStart { set; get; }

        /// <summary>
        /// 預約Id
        /// </summary>      
        public int? reservationId { set; get; }

        /// <summary>
        /// 開始交易的時間
        /// </summary>
        [Required]
        [JsonConverter(typeof(UTCDateTimeConverter))]
        public DateTime timestamp { set; get; }

        public bool TransactionRelated()
        {
            return true;
        }

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