@@ -26,8 +26,8 @@ public int getId() {
26
26
return id ;
27
27
}
28
28
29
- public static HttpURLConnection makeHttpConnection (URL url ) throws IOException {
30
- Settings settings = Settings . getInstance ( );
29
+ public static HttpURLConnection makeHttpConnection (URL url , Settings settings ) throws IOException {
30
+ System . out . println ( "makeHttpConnection: " + settings . getKimaiUsername () + ", " + settings . getKimaiPassword () + ", " + ", " + settings . getKimaiUri () );
31
31
HttpURLConnection con = (HttpURLConnection ) url .openConnection ();
32
32
con .setRequestProperty ("X-AUTH-USER" , settings .getKimaiUsername ());
33
33
con .setRequestProperty ("X-AUTH-TOKEN" , settings .getKimaiPassword ());
@@ -36,25 +36,25 @@ public static HttpURLConnection makeHttpConnection(URL url) throws IOException {
36
36
return con ;
37
37
}
38
38
39
- public static String getApi (URL url ) throws ConfigNotInitialisedException , IOException {
40
- return Entity .getApi (url , null );
39
+ public static String getApi (URL url , Settings settings ) throws IOException {
40
+ return Entity .getApi (url , settings , null );
41
41
}
42
42
43
- public static String getApi (URL url , List <Map .Entry <String , String >> parameters ) throws ConfigNotInitialisedException , IOException {
43
+ public static String getApi (URL url , Settings settings , List <Map .Entry <String , String >> parameters ) throws IOException {
44
44
if (parameters != null && parameters .size () > 0 ) {
45
45
StringBuilder query = new StringBuilder ();
46
46
for (Map .Entry <String , String > parameter : parameters ) {
47
47
query .append (String .format ("%s=%s&" , URLEncoder .encode (parameter .getKey (), "UTF-8" ), URLEncoder .encode (parameter .getValue (), "UTF-8" )));
48
48
}
49
49
url = new URL (url + "?" + query );
50
50
}
51
- HttpURLConnection con = makeHttpConnection (url );
51
+ HttpURLConnection con = makeHttpConnection (url , settings );
52
52
53
53
return callApi (con );
54
54
}
55
55
56
- public static String postApi (URL url , String body ) throws ConfigNotInitialisedException , IOException {
57
- HttpURLConnection con = makeHttpConnection (url );
56
+ public static String postApi (URL url , Settings settings , String body ) throws IOException {
57
+ HttpURLConnection con = makeHttpConnection (url , settings );
58
58
con .setDoOutput (true );
59
59
con .setRequestProperty ("Content-Type" , "application/json" );
60
60
OutputStream os = con .getOutputStream ();
0 commit comments