package cz.moneta.test.dsl.openapi;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.harness.endpoints.openapi.OpenApiEndpoint;
import cz.moneta.test.harness.support.rest.RawRestRequest;

public class OpenApiBuilder extends OpenApiBaseBuilder {

    private static final String SECURED_URL_PART = "secured/";
    private static final String UNSECURED_URL_PART = "unsecured/";

    public OpenApiBuilder(Harness harness) {
        super(harness);
    }

    public RawRestRequest.Path prepareRequest() {
        return RawRestRequest.jsonBuilder(harness.getEndpoint(OpenApiEndpoint.class));
    }

    public RawRestRequest.Path prepareSecuredRequest() {
        return prepareRequestPathPrefix(SECURED_URL_PART);
    }

    public RawRestRequest.Path prepareUnsecuredRequest() {
        return prepareRequestPathPrefix(UNSECURED_URL_PART);
    }

    private RawRestRequest.Path prepareRequestPathPrefix(String pathPrefix) {
        OpenApiEndpoint endpoint = harness.getEndpoint(OpenApiEndpoint.class);
        return RawRestRequest.jsonBuilder(endpoint)
                .setPathPrefix(pathPrefix);
    }
}
