using Edge.Core.Parser.BinaryParser.Attributes;
using HengshanPaymentTerminal.Support;
using System;
using System.Collections.Generic;
using System.Text;

namespace  HengshanPaymentTerminal.MessageEntity.Incoming
{
    /// <summary>
    /// Request from pump to system to initiate a payment.
    /// 加油机/终端向后台发起扣款请求。
    /// </summary>
    public class PaymentRequest : CardMessageBase
    {
        #region Constructor

        public PaymentRequest() : base(Command.PaymentRequest)
        {

        }

        #endregion

        #region Properties

        [Format(4, EncodingType.BcdString, -90)]
        public string TerminalId { get; set; }

        [Format(10, EncodingType.BcdString, -89)]
        public string Asn { get; set; }

        [Format(7, EncodingType.BcdString, -88)]
        public string AuthTime { get; set; }

        [Format(4, EncodingType.BIN, -87)]
        public int PosTtc { get; set; }

        [Format(2, EncodingType.BIN, -86)]
        public ushort SeqNo { get; set; }

        [Format(2, EncodingType.HexString, -85)]
        public string FPCode { get; set; }

        public FuelingPointCode FuelingPoint
        {
            get
            {
                return new FuelingPointCode
                {
                    NozzleNo = FPCode.Substring(0, 2).ToByte(),
                    PumpNo = FPCode.Substring(2, 2).ToByte()
                };
            }
        }

        #endregion
    }
}
