package cz.moneta.test.dsl.payment_engine;

import cz.moneta.test.dsl.payment_engine.enums.PaymentDirection;
import cz.moneta.test.dsl.payment_engine.enums.PaymentType;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.payment_engine.PaymentEngineCreateReservationPage.SELECT_TYPE;

@Wait(SELECT_TYPE)
public interface PaymentEngineCreateReservationPage extends WebFlow<PaymentEngineCreateReservationPage> {

    String AMOUNT = "//tbody//input[@name = 'amt']";
    String DESCRIPTION_1 = "//tbody//input[@name = 'line1']";
    String DESCRIPTION_2 = "//tbody//input[@name = 'line2']";
    String DESCRIPTION_3 = "//tbody//input[@name = 'line3']";
    String SELECT_TYPE = "//div[label[text() = 'Typ blokace']]//input[@name = 'type']//following-sibling::img";
    String PAYMENT_TYPE = "//div[div[contains(@class, 'x-combo-selected') and text() = 'Karetní']]//div[text() = '%s']";
    String SELECT_DIRECTION = "//div[label[text() = 'Debet/Kredit']]//input[@name = 'direction']//following-sibling::img";
    String PAYMENT_DIRECTION = "//div[text() = '%s']";
    String SUBMIT_BUTTON = "//button[text()='OK']";
    String EXTERNAL_ID = "//tbody//input[@name='extId']";
    String CREATED_DATE = "//input[@name='created']//following-sibling::input";
    String ACCOUNT_DAY = "//input[@name='accDate']//following-sibling::input";
    String CARD_NUMBER = "//input[@name = 'cardNumber']";
    String AUTHOR_CODE = "//input[@name = 'authCode']";

    @Click(SELECT_TYPE)
    PaymentEngineCreateReservationPage clickOnSelectType();

    @Wait(value = PAYMENT_TYPE)
    @Click(value = PAYMENT_TYPE)
    PaymentEngineCreateReservationPage selectType(PaymentType paymentType);

    @Click(SELECT_DIRECTION)
    PaymentEngineCreateReservationPage clickOnDirection();

    @Wait(value = PAYMENT_DIRECTION)
    @Click(value = PAYMENT_DIRECTION)
    PaymentEngineCreateReservationPage selectDirection(PaymentDirection paymentDirection);

    @TypeIntos({@TypeInto(AMOUNT), @TypeInto(DESCRIPTION_1), @TypeInto(value = DESCRIPTION_2, andWait = @Wait(explicitWaitSeconds = 1))})
    PaymentEngineCreateReservationPage fillManualData(String amount, String description_1, String description_2);

    @TypeIntos({@TypeInto(EXTERNAL_ID), @TypeInto(AMOUNT), @TypeInto(CREATED_DATE), @TypeInto(ACCOUNT_DAY), @TypeInto(DESCRIPTION_1), @TypeInto(DESCRIPTION_3), @TypeInto(CARD_NUMBER), @TypeInto(value = AUTHOR_CODE, andWait = @Wait(explicitWaitSeconds = 1))})
    PaymentEngineCreateReservationPage fillCardData(String externalID, String amount, String createdDate, String accountDay, String description_1, String description_3, String cardId, String authorizationCode);

    @Click(value = SUBMIT_BUTTON, andWait = @Wait(value = SUBMIT_BUTTON, until = Until.GONE))
    PaymentEngineReservationPage clickSubmit();
}
