package cz.moneta.test.sanity.transactional.cards.firstvision;

import com.fasterxml.jackson.annotation.JsonProperty;
import cz.moneta.test.dsl.Harness;
import cz.moneta.test.harness.annotations.Environment;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.sanity.transactional.SmokeData;
import lombok.Data;

import static cz.moneta.test.sanity.transactional.cards.firstvision.MESSAGE.*;

@TestScenario(name = "M.FAS.AUTH.REQST.REV.UPD R8V2")
public class Authentication {

    private final String VMX_MSGIN_DATE_EXPIRE = "VMX_MSGIN.DATE_EXPIRE";

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T4633")
    public void M_FAS_AUTH_REQST_REV_UPD(Harness harness) {
        String card = SmokeData.getInstance(harness).getCreditData().getCard();
        harness.withWso2()
                .prepareRequest()
                .withPath(FV)
                .withPojoPayload(new MESSAGE("M.FAS.AUTH.REQST.REV.UPD", "R8V2"))
                .addField(VMX_MSGIN, "CARD_NBR", card)
                .addField(VMX_MSGIN, "STORE_NBR", "999999998")
                .addField(VMX_MSGIN, "AMT", "70000")
                .addField(VMX_MSGIN, "PLAN", "10002")
                .addField(VMX_MSGIN, "ACTION_CODE", "AUTH")
                .addField(VMX_MSGIN, "SERVICE_FLAG", "A")
                .addField(VMX_MSGIN, "SEC_PRES_IND", "0")
                .addField(VMX_MSGIN, "DATE_EXPIRE", new DATE_EXPIRE())
                .addField(VMX_MSGIN_DATE_EXPIRE, "DATE_EXPIRE_MM", "8")
                .addField(VMX_MSGIN_DATE_EXPIRE, "DATE_EXPIRE_YY", "23")
                .postExtended()
                .andAssertFieldValue(SVC_RETURN, "P");
    }

    @Data
    private static class DATE_EXPIRE {
        @JsonProperty("DATE_EXPIRE_MM")
        private String monthExpire;
        @JsonProperty("DATE_EXPIRE_YY")
        private String yearExpire;
    }
}
