@@ -30,11 +30,11 @@ class NetworkUtils {
3030 }
3131
3232 /* *
33- * Sends a GET request to the given URI and returns the response as a JSONObject .
33+ * Sends a GET request to the given URI and returns the response as a String .
3434 *
35- * @return The response body as a JSONObject .
35+ * @return The response body as String .
3636 */
37- fun URI.get (): JSONObject {
37+ fun URI.get (): String {
3838 val response = HttpClient .newBuilder()
3939 .build()
4040 .send(
@@ -43,27 +43,25 @@ class NetworkUtils {
4343 .build(),
4444 HttpResponse .BodyHandlers .ofString()
4545 )
46- return JSONObject ( response.body() )
46+ return response.body()
4747 }
4848
4949 /* *
50- * Sends a POST request to the given URI with the specified JSON body.
50+ * Sends a POST request to the given URI with the specified body and returns the response as a String .
5151 *
52- * @param body The JSON body to be sent in the POST request.
52+ * @param body The body of the POST request.
53+ * @return The response body as String.
5354 */
54- fun URI.post (body : JSONObject ) {
55- HttpClient .newBuilder()
55+ fun URI.post (body : String ): String {
56+ return HttpClient .newBuilder()
5657 .build()
5758 .send(
5859 HttpRequest .newBuilder(this )
5960 .header(" Content-Type" , " application/json" )
60- .POST (HttpRequest .BodyPublishers .ofString(JSONObject ().apply {
61- put(" functionName" , " ping" )
62- put(" functionArgs" , JSONObject ())
63- }.toString()))
61+ .POST (HttpRequest .BodyPublishers .ofString(body))
6462 .build(),
6563 HttpResponse .BodyHandlers .ofString()
66- )
64+ ).body()
6765 }
6866 }
6967}
0 commit comments