package cz.moneta.test.dsl.udebs;

import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.udebs.UdebsEndpoint;
import org.jooq.Record;
import org.jooq.Result;

public class TransactionForKycBuilder {
    private final StoreAccessor harness;

    public TransactionForKycBuilder(StoreAccessor harness) {
        this.harness = harness;
    }

    public Result<Record> getTransaction(String dateFrom, String dateTo, String clientId, String state) {
        return harness.getEndpoint(UdebsEndpoint.class).executeSql(
                "SELECT \n" +
                        "P.OPERID,P.CHANNELID,P.STATUSID,UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(T.RAWDATA,3200,1)) AS DATA  \n" +
                        "FROM \n" +
                        "W_CLIENTTRANSACTIONPACKAGES P, UDEBSGE.W_TRANSACTIONS T \n" +
                        "WHERE P.PACKAGEID BETWEEN GE_SEQ.GET_PACKAGEID('" + dateFrom + "') \n" +
                        "AND GE_SEQ.GET_PACKAGEID('" + dateTo + "') \n" +
                        "AND P.PACKAGEID = T.PACKAGEID(+) \n" +
                        "AND P.CLIENTID = " + clientId + "\n" +
                        "AND UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(T.RAWDATA,3200,1)) LIKE '%" + state + "%'");
    }
}
