|
| 1 | +import org.openapitools.client.api.UsersApi; |
| 2 | +import ProcessMaker_Client.ApiClient; |
| 3 | +import com.google.gson.Gson; |
| 4 | +import java.io.*; |
| 5 | +import java.lang.reflect.Type; |
| 6 | +import com.google.gson.reflect.TypeToken; |
| 7 | +import java.util.Map; |
| 8 | +import java.util.HashMap; |
| 9 | + |
| 10 | +public class Spark { |
| 11 | + |
| 12 | + public static ApiClient api() { |
| 13 | + String baseApiUrl = System.getenv("API_HOST"); |
| 14 | + String v3Token = System.getenv("API_TOKEN"); |
| 15 | + int connectTimeout = 60000; |
| 16 | + int readTimeout = 120000; |
| 17 | + |
| 18 | + ApiClient client = new ApiClient(); |
| 19 | + |
| 20 | + client.setBasePath(baseApiUrl); |
| 21 | + client.setApiKey("Bearer " + v3Token); |
| 22 | + client.setConnectTimeout(connectTimeout); |
| 23 | + client.setDebugging(false); |
| 24 | + return client; |
| 25 | + } |
| 26 | + |
| 27 | + public static Map<String, Object> data() throws FileNotFoundException { |
| 28 | + Type typeOfHashMap = new TypeToken<Map<String, Object>>() { }.getType(); |
| 29 | + BufferedReader bufferedReader = new BufferedReader(new FileReader("data.json")); |
| 30 | + Gson gson = new Gson(); |
| 31 | + return gson.fromJson(bufferedReader, typeOfHashMap); |
| 32 | + } |
| 33 | + |
| 34 | + public static Map<String, Object> config() throws FileNotFoundException { |
| 35 | + Type typeOfHashMap = new TypeToken<Map<String, Object>>() { }.getType(); |
| 36 | + BufferedReader bufferedReader = new BufferedReader(new FileReader("config.json")); |
| 37 | + Gson gson = new Gson(); |
| 38 | + return gson.fromJson(bufferedReader, typeOfHashMap); |
| 39 | + } |
| 40 | + |
| 41 | + public static void printOutput(Map<String, Object> data) { |
| 42 | + String jsonString = new Gson().toJson(data); |
| 43 | + System.out.println(jsonString); |
| 44 | + } |
| 45 | +} |
0 commit comments