package cz.moneta.test.regression.channels.digital.ib.newib.payment.fop;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.newib.tasks.NewIbTasks;
import cz.moneta.test.dsl.newib.util.PaymentFormData;
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.TestScenarioWithOrder;
import cz.moneta.test.harness.support.auth.Credentials;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Order;

@TestScenarioWithOrder(name = "Other payments tests")
public class OtherPaymentsTest {
    Credentials clientCredentials;
    PaymentFormData formData;

    @BeforeAll
    public void setup(Harness harness) {

        clientCredentials = harness.tasks()
                .udebs()
                .findCredentialsByRC("7052270269");

        formData = PaymentFormData.builder()
                .fromAccountNumber("236142179/0600")
                .recipientAccountNumberCzk("3681-7127701/0600")
                .build();
    }

    @Order(1)
    @TestCase(name = "Download cash receipts", environments = {Environment.PPE})
    @JiraTestCase(id = "SB-T9260")
    public void downloadCashReceiptsFop(Harness harness) {
        NewIbTasks newIbTasks = harness.tasks().newIb();

        harness.withNewIb()
                .openLoginPage()
                .then(newIbTasks.loginWithUsernamePasswordAndDefaultMobKey(clientCredentials.getUsername(), clientCredentials.getPassword()))
                .then(newIbTasks.downloadCashReceipts(formData));

        harness.withOpenApi()
                .prepareUnsecuredRequest()
                .withPath("/account/transaction/receipt")
                .withHeader("dispo-context-id", "10021778")
                .withPayload("{\"transactionId\":\"0236142179:20251231:00001:251231GTA990002\"}")
                .post()
                .andAssertFieldValue("status", "OK")
                .saveBase64FieldAsFile("responseObject.base64PdfReceipt");
    }
}