package com.brilliance.isc.swift.objmtconvert.model.mt7xx;

import com.brilliance.isc.swift.objmtconvert.annotation.FieldDescription;
import com.brilliance.isc.swift.objmtconvert.annotation.Status;
import com.brilliance.isc.swift.objmtconvert.annotation.TagName;
import com.brilliance.isc.swift.objmtconvert.annotation.TagRegex;
import com.brilliance.isc.swift.objmtconvert.model.AbsMTCreator;
import com.brilliance.isc.swift.objmtconvert.model.AbsTagCreate;
import com.brilliance.isc.swift.objmtconvert.model.commontag.ActnoBicAdrTagXXX;
import com.brilliance.isc.swift.objmtconvert.model.commontag.DcDateCurAmtTagXXX;
import com.brilliance.isc.swift.objmtconvert.model.mt7xx.tag.tag765.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;


import java.util.ArrayList;
import java.util.List;
@Data
public class MT765Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String transactionReferenceNumber;

    @Status("M")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    //21
    private String relatedReference;

    @Status("O")
    @TagName("23")
    @FieldDescription("Beneficiary Reference Number")
    @TagRegex("16x")
    private String beneficiaryReferenceNumber;

    @Status("M")
    @TagName({"52A","52D"})
    @FieldDescription("Issuer")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX issuer52a;

    @Status("O")
    @TagName({"59","59A"})
    @FieldDescription("Beneficiary")
    @TagRegex({"[/34x]<crlf>4*35x","[/34x]<crlf>4!a2!a2!c[3!c]"})
    private ActnoBicAdrTagXXX beneficiary59a;

    @Status("O")
    @TagName("31L")
    @FieldDescription("Date of Demand")
    @TagRegex({"6!n"})
    private String  dateOfDemand;

    @Status("M")
    @TagName("22G")
    @FieldDescription("Demand Type")
    @TagRegex({"4!c"})
    private String  demandType;

    @Status("M")
    @TagName("32B")
    @FieldDescription("Demand Amount")
    @TagRegex({"3!a15d"})
    private DcDateCurAmtTagXXX demandAmount32B;

    @Status("O")
    @TagName("78")
    @FieldDescription("Additional Amount Information")
    @TagRegex({"12*65x"})
    private String  additionalAmountInformation;

    @Status("O")
    @TagName("49A")
    @FieldDescription("Demand Statement")
    @TagRegex({"4!c<crlf>[50*65z]"})
    private String  demandStatement;

    @Status("O")
    @TagName("77")
    @FieldDescription("Presentation Completion Details")
    @TagRegex({"20*35z"})
    private String  presentationCompletionDetails;

    @Status("O")
    @TagName("31E")
    @FieldDescription("Requested New Date of Expiry")
    @TagRegex({"6!n"})
    private String  requestedNewDateofExpiry;

    @Status("O")
    @TagName("31R")
    @FieldDescription("Requested New Date of Expiry of Local Undertaking")
    @TagRegex({"6!n"})
    private String requestedNewDateofExpiryofLocalUndertaking;

    @Status("O")
    @TagName({"56A","56B","56D"})
    @FieldDescription("Intermediary")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX  intermediary56a;

    @Status("O")
    @TagName({"57A","57B","57D"})
    @FieldDescription("Account With Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x]","[/1!a][/34x]<crlf>4*35x"})
    private ActnoBicAdrTagXXX  accountWithInstitution57a;

    @Status("O")
    @TagName("72Z")
    @FieldDescription("Sender to Receiver Information")
    @TagRegex({"6*35z"})
    private String  sendertoReceiverInformation;

    @Status("O")
    @TagName("23X")
    @FieldDescription("File Identification")
    @TagRegex({"4!c/65x"})
    private String  fileIdentification;


    public MT765Creator(String msgType)  {
        super(msgType);
    }

    public MT765Creator() {
        super("765");
    }

    public void pack() {
        //MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList = new ArrayList<>();
        try {
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag23Creator(this));
            tagCreateList.add(new Tag52aCreator(this));
            tagCreateList.add(new Tag59aCreator(this));
            tagCreateList.add(new Tag31LCreator(this));
            tagCreateList.add(new Tag22GCreator(this));
            tagCreateList.add(new Tag32BCreator(this));
            tagCreateList.add(new Tag78Creator(this));
            tagCreateList.add(new Tag49ACreator(this));
            tagCreateList.add(new Tag77Creator(this));
            tagCreateList.add(new Tag31ECreator(this));
            tagCreateList.add(new Tag31RCreator(this));
            tagCreateList.add(new Tag56aCreator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new Tag72ZCreator(this));
            tagCreateList.add(new Tag23XCreator(this));

            dealTags(tagCreateList);

            mtResult.setMessage(abstractMT.message());
        } catch (Exception e) {
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }

        // return mtResult;

    }
    public MtResult unpack() {
        return null;
    }
}
