package cz.moneta.test.regression.cvm.api.cvm;

import com.fasterxml.jackson.databind.JsonNode;
import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.DateUtils;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;

import java.util.UUID;

import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@TestScenario(name = "Call API sb-unified-onboarding-trigger to WSO2 and assert response parameters")
public class ApiSbUnifiedOnboardingTrigger {

    @TestCase(name = "Call API sb-unified-onboarding-trigger to WSO2", environments = {TST1, PPE})
    public void postSbUnifiedOnboardingTrigger(Harness harness) {
        JsonNode outputs = harness.tasks().wso2().restRequest().prepareRequestFromCvm(
                "cvm.cluster/sb-unified-onboarding-trigger/1.0.0", false,
                "{\n" +
                        "    \"version\": 1,\n" +
                        "    \"clientTimeZone\": \"Europe/Prague\",\n" +
                        "    \"correlationId\": \"" + UUID.randomUUID() + "\",\n" +
                        "    \"inputs\": {\n" +
                        "        \"appKey\": null,\n" +
                        "        \"birthNumber\": \"8812210022\",\n" +
                        "        \"channel\": \"SBA\",\n" +
                        "        \"cif\": null,\n" +
                        "        \"configurationEventDelay\": 3600,\n" +
                        "        \"email\": \"prijde.pushka.pro.sb.onboarding@neexistujicidomana.com\",\n" +
                        "        \"eventDateTime\": \"" + DateUtils.getFormattedTodayDateTimeForWso2() + "\",\n" +
                        "        \"firstName\": \"Prijde\",\n" +
                        "        \"lastName\": \"Pushka\",\n" +
                        "        \"marketingCnst\": true,\n" +
                        "        \"phoneNumber\": \"+420725810843\",\n" +
                        "        \"productClass\": \"12\",\n" +
                        "        \"promotion\": null,\n" +
                        "        \"screenId\": \"ONBOARDING\",\n" +
                        "        \"status\": \"OK\",\n" +
                        "        \"transactionId\": null,\n" +
                        "        \"unecncryptedCommunicationCnst\": true,\n" +
                        "        \"userId\": null,\n" +
                        "        \"wfId\": null,\n" +
                        "        \"wustenrotClientFlag\": true\n" +
                        "    }\n" +
                        "}")
                .post()
                .andAssertStatus(201)
                .extract("outputs");

        harness.tasks().cvm().cvmWso2().assertResponseOutputs(outputs);
    }
}

