-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessMaker.java
More file actions
60 lines (50 loc) · 1.98 KB
/
Copy pathProcessMaker.java
File metadata and controls
60 lines (50 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import ProcessMaker_Client.ApiClient;
import com.google.gson.Gson;
import java.io.*;
import java.lang.reflect.Type;
import com.google.gson.reflect.TypeToken;
import java.util.Map;
import java.util.HashMap;
public class ProcessMaker {
public static ApiClient api() {
String baseApiUrl = System.getenv("API_HOST");
String v3Token = System.getenv("API_TOKEN");
String verifySsl = System.getenv("API_SSL_VERIFY");
int connectTimeout = 60000;
int readTimeout = 120000;
ApiClient client = new ApiClient();
client.setBasePath(baseApiUrl);
if(v3Token != null && !v3Token.isEmpty()) {
client.setBearerToken(v3Token);
}
client.setConnectTimeout(connectTimeout);
client.setDebugging(false);
if (verifySsl.equals("0")) {
client.setVerifyingSsl(false);
}
return client;
}
public static Map<String, Object> data() throws FileNotFoundException {
Type typeOfHashMap = new TypeToken<Map<String, Object>>() { }.getType();
BufferedReader bufferedReader = new BufferedReader(new FileReader("data.json"));
Gson gson = new Gson();
return gson.fromJson(bufferedReader, typeOfHashMap);
}
public static Map<String, Object> config() throws FileNotFoundException {
Type typeOfHashMap = new TypeToken<Map<String, Object>>() { }.getType();
BufferedReader bufferedReader = new BufferedReader(new FileReader("config.json"));
Gson gson = new Gson();
return gson.fromJson(bufferedReader, typeOfHashMap);
}
public static void printOutput(Map<String, Object> data) {
String jsonString = new Gson().toJson(data);
// System.out.println(jsonString);
try {
Writer fileWriter = new FileWriter("output.json", false);
fileWriter.write(jsonString);
fileWriter.close();
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
}