package cz.moneta.test.dsl.util.task.oauth2.token;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.cagw.oauth2.token.Oauth2Token;
import cz.moneta.test.dsl.cagw.api.v4.token.ApiV4Token;
import cz.moneta.test.dsl.oauth2.web.ThirdPartyApplicationPageWithToken;

import java.util.function.Function;

public class TokenTasks {

    private final Harness harness;

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

    public Function<Oauth2Token, Oauth2Token> setRequestValues(String oauth2ClientId, String oauth2ClientSecret) {
        return start -> start.code(harness.get(ThirdPartyApplicationPageWithToken.AUTH_CODE_STORE))
                .client_id(oauth2ClientId)
                .client_secret(oauth2ClientSecret)
                .grant_type("authorization_code");
    }

    public Function<ApiV4Token, ApiV4Token> setRequestValuesV2(String oauth2ClientId, String oauth2ClientSecret) {
        return start -> start.code(harness.get(ThirdPartyApplicationPageWithToken.AUTH_CODE_STORE))
                .client_id(oauth2ClientId)
                .client_secret(oauth2ClientSecret)
                .grant_type("authorization_code");
    }
}
