package cz.moneta.test.dsl.util.task.cagw.api;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.cagw.api.cbl.psd.pisp.my.payments.paymentid.status.Status;
import cz.moneta.test.dsl.cagw.api.cbl.psd.pisp.my.payments.paymentid.status.StatusResponse;

import java.util.function.Function;

public class StatusTasks {

    private final Harness harness;

    public StatusTasks(Harness harness) {
        this.harness = harness;
    }

    public Function<Status, Status> setRequestValues(String authToken, String transId) {
        return start -> start.withAuthorizationBearer("Bearer " + authToken)
                .paymentId(transId);
    }

    public Function<Status, StatusResponse> sendAndWaitForStatus(String status) {
        return start -> start.pollUntil(StatusResponse::getInstructionStatus)
                .maxRetries(40)
                .retryDelayMillis(3000)
                .isEqual(status);
    }
}
