package eu.hsrw.ias.ggd;

import Credentials.PlonkTest;
import HttpCall.HttpPost;
import HttpCall.PlonkHttpPost;

public class PlonkHttpPostRequest {
    public static String OnCallMethod()
            throws Exception {
        PlonkTest plonkTest = new PlonkTest();
        PlonkHttpPost plonkHttpPost = new PlonkHttpPost();

        //creating the request URL
        String url = plonkTest.getServer() + "/auth/realms/" + plonkTest.getRealm() + "/protocol/openid-connect/token";
        //creating the body of the request
        String data = String.format("grant_type=%s&client_id=%s&username=%s&password=%s&client_secret=%s", plonkTest.getGrantType(), plonkTest.getClientId(), plonkTest.getUsername(), plonkTest.getPassword(), plonkTest.getClientSecret());

        return plonkHttpPost.PlonkHttpCallPost(url, data);
    }


//    public static void main(String[] args) {
//        try {
//            String output = OnCallMethod();
//            System.out.println(output);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
}