package cz.moneta.test.harness.support.mwf;

import cz.moneta.test.harness.context.StoreAccessor;

import cz.moneta.test.harness.support.util.Builder;
import cz.moneta.test.harness.support.util.RequestPoll;
import cz.moneta.test.harness.support.util.Level;

import java.util.function.Function;

/**
 * This ss the marker interface of MWF request builder proxies.
 * <p/>
 * The builders are usually accessed via {@code harness.withIHub()} or similar method where the proxy
 * is instantiated by calling the respective
 * {@link Builders#newMwfBuilder(Class, TifClient, StoreAccessor)} method.
 * <p/>
 * An example MWF builder may look as follows:
 * <pre>{@code
 * @literal @ApiVersion(versionTST1 = "765")
 *  public interface MWF109 extends MwfRequest<MWF109, MWF109Response> {
 *
 *     @literal @Parameter(name = "Adresat")
 *      MWF109 Adresat(String Adresat);
 *     @literal @Parameter(name = "CO")
 *      MWF109 Co(String Co);
 *     @literal @Parameter(name = "CP")
 *      MWF109 Cp(String Cp);
 *     @literal @Parameter(name = "CisloPasu")
 *      MWF109 CisloPasu(String CisloPasu);
 *     @literal @Parameter(name = "CistyMesicniPrijem")
 *      MWF109 CistyMesicniPrijem(Double CistyMesicniPrijem);
 *     @literal @Parameter(name = "Ctvrt")
 *      MWF109 Ctvrt(String Ctvrt);
 *     @literal @Parameter(name = "DatumExpiraceKontaktnichUdaju")
 *      MWF109 DatumExpiraceKontaktnichUdaju(java.util.Date DatumExpiraceKontaktnichUdaju);
 *     @literal @Parameter(name = "DatumExpiracePotvrzeniStudent")
 *      MWF109 DatumExpiracePotvrzeniStudent(java.util.Date DatumExpiracePotvrzeniStudent);
 *     @literal @Parameter(name = "DatumNarozeni")
 *      MWF109 DatumNarozeni(java.util.Date DatumNarozeni);
 *      ...
 *  }
 * }</pre>
 * And the usage would be as follows:
 * <pre>{@code
 *  MWF109Response resp = harness.withIHub()
 *      .prepareRequestAsUfo(MWF109.class)
 *      .RodneCislo(client.birthNumber())
 *      .DatumNarozeni(TestUtils.dateFromString(client.birthDate(), "d.M.yyyy"))
 *      ...
 *      .send();
 * }</pre>
 *
 * Please note that each MWF builder must have its corresponding DAPI xml mapping available on classpath so that
 * DAPI calls may be executed successfully
 *
 * @see Parameter
 * @see ApiVersion
 */
public interface MwfRequest<B, RESP> extends Builder<B> {
    RESP send();

    RequestPoll<RESP> pollUntil(Function<RESP, Object> extractor);

    B log(String template, Function<RESP, Object>... args);

    B log(Level level, String template, Function<RESP, Object>... args);
}
