package cz.moneta.test.dsl.udebs;

import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.udebs.UdebsEndpoint;

public class UsersTable {
    private final StoreAccessor harness;

    private final String CLIENTID_USERS = "SELECT CLIENTID FROM USERS WHERE RC_NUMBER='%s'";

    private final String USERID_USERS = "SELECT USERID FROM USERS WHERE RC_NUMBER='%s'";

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

    public String getClientId(String birthNumber) {
        return harness.getEndpoint(UdebsEndpoint.class)
                .executeSql(String.format(CLIENTID_USERS, birthNumber))
                .getValues("CLIENTID")
                .get(0)
                .toString();
    }

    public String getUserId(String birthNumber) {
        return harness.getEndpoint(UdebsEndpoint.class)
                .executeSql(String.format(USERID_USERS, birthNumber))
                .getValues("USERID")
                .get(0)
                .toString();
    }
}