using System;
using adMoto.Payments.Core.Data;

namespace adMoto.Payments.Core
{
    public class Merchant
    {
        public const string BAD_HASH = "zlyHash";                  //błędne hasło - odpowiedź z eCard
        public const string HASH_ERROR_INFO = "payment not exist";

        public string Id { get; set; }
        public string Password { get; set; }
        public PlatnosciEcard Payment { get; set; }
        public string SystemKsiegowy { get; set; }
        public string Hash { get; set; }
        public string LinkFail { get; set; }
        public string LinkOk { get; set; }
        public string Error {get; set;}
        
        public void IsValid()
        {
            if (Payment == null) Error = "payment";
            else if (Payment != null)
            {
                if (Payment.AMOUNT < 0) Error = "amount";
                else if (Payment.AUTODEPOSIT != true) Error = "autodeposit";
                else if (String.IsNullOrEmpty(Payment.ORDERDESCRIPTION)) Error = "orderdescription";
                else if (String.IsNullOrEmpty(Payment.CURRENCY)) Error = "currency";
                else if (String.IsNullOrEmpty(Payment.NAME)) Error = "name";
                else if (String.IsNullOrEmpty(Payment.SURNAME)) Error = "surname";
                else if (String.IsNullOrEmpty(Payment.LANGUAGE)) Error = "language";
            }
            if (String.IsNullOrEmpty(Error))
            {
                if (Hash == BAD_HASH || Hash == "" || Hash == HASH_ERROR_INFO) Error = "hash";
                else if (String.IsNullOrEmpty(Id)) Error = "id";
                else if (String.IsNullOrEmpty(Password)) Error = "password";
                else if (String.IsNullOrEmpty(Hash)) Error = "hash";
                else if (String.IsNullOrEmpty(LinkFail)) Error = "linkfail";
                else if (String.IsNullOrEmpty(LinkOk)) Error = "linkok";
            }
        }
    }
}