@@ -77,7 +77,11 @@ public ApiClient(String baseUrlLambda) {
7777 public Mono <ApiFactory > callAPIGet (String routeName ) {
7878 connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.get" , Map .of ("routename" , routeName )));
7979
80- Request r = DataController .getInstance ().createRequest (routeName , baseUrl );
80+ AtomicReference <Request > requestRef = new AtomicReference <>();
81+
82+ if (connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().IS_APP_RUNNING ).equals (true )) {
83+ requestRef .set (DataController .getInstance ().createRequest (routeName , baseUrl ));
84+ }
8185
8286 record ResponseData (int statusCode , String body ) {}
8387
@@ -93,14 +97,19 @@ record ResponseData(int statusCode, String body) {}
9397
9498 String newStatus = (responseData .statusCode () >= 200 && responseData .statusCode () < 300 ) ? "success" : "error" ;
9599 try {
96- DataController .getInstance ().updateRequestStatus (r .getId (), newStatus );
100+ if (connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().IS_APP_RUNNING ).equals (true )) {
101+ Request r = requestRef .get ();
102+ if (r != null ) {
103+ DataController .getInstance ().updateRequestStatus (r .getId (), newStatus );
104+ }
105+ }
97106 } catch (Exception e ) {
98107 connectLib .Logger ().CRITICAL (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "general.error" , Map .of ("method" , "GET" , "exception" , e .getMessage ())));
99108 }
100109 })
101110 .map (responseData -> {
102111 apiFactory .setStatusCode (responseData .statusCode ());
103- apiFactory .parseFromRawJson (responseData .body );
112+ apiFactory .parseFromRawJson (responseData .body () );
104113 return apiFactory ;
105114 })
106115 .doOnNext (lastResponse ::set )
@@ -116,7 +125,11 @@ record ResponseData(int statusCode, String body) {}
116125 public Mono <ApiFactory > callAPIPost (String routeName , Map <String , Object > body ) {
117126 connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.post" , Map .of ("routename" , routeName )));
118127
119- Request r = DataController .getInstance ().createRequest (routeName , baseUrl );
128+ AtomicReference <Request > requestRef = new AtomicReference <>();
129+
130+ if (connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().IS_APP_RUNNING ).equals (true )) {
131+ requestRef .set (DataController .getInstance ().createRequest (routeName , baseUrl ));
132+ }
120133
121134 record ResponseData (int statusCode , String body ) {}
122135
@@ -133,7 +146,12 @@ record ResponseData(int statusCode, String body) {}
133146
134147 String newStatus = (responseData .statusCode () >= 200 && responseData .statusCode () < 300 ) ? "success" : "error" ;
135148 try {
136- DataController .getInstance ().updateRequestStatus (r .getId (), newStatus );
149+ Request r = requestRef .get ();
150+ if (r != null ) {
151+ if (connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().IS_APP_RUNNING ).equals (true )) {
152+ DataController .getInstance ().updateRequestStatus (r .getId (), newStatus );
153+ }
154+ }
137155 } catch (Exception e ) {
138156 connectLib .Logger ().CRITICAL (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "general.error" , Map .of ("method" , "GET" , "exception" , e .getMessage ())));
139157 }
@@ -156,7 +174,10 @@ record ResponseData(int statusCode, String body) {}
156174 public Mono <ApiFactory > callAPIPut (String routeName , Map <String , Object > body ) {
157175 connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.put" , Map .of ("routename" , routeName )));
158176
159- Request r = DataController .getInstance ().createRequest (routeName , baseUrl );
177+ AtomicReference <Request > requestRef = new AtomicReference <>();
178+ if (connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().IS_APP_RUNNING ).equals (true )) {
179+ requestRef .set (DataController .getInstance ().createRequest (routeName , baseUrl ));
180+ }
160181
161182 record ResponseData (int statusCode , String body ) {}
162183
@@ -173,9 +194,14 @@ record ResponseData(int statusCode, String body) {}
173194
174195 String newStatus = (responseData .statusCode () >= 200 && responseData .statusCode () < 300 ) ? "success" : "error" ;
175196 try {
176- DataController .getInstance ().updateRequestStatus (r .getId (), newStatus );
197+ if (connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().IS_APP_RUNNING ).equals (true )) {
198+ Request r = requestRef .get ();
199+ if (r != null ) {
200+ DataController .getInstance ().updateRequestStatus (r .getId (), newStatus );
201+ }
202+ }
177203 } catch (Exception e ) {
178- connectLib .Logger ().CRITICAL (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "general.error" , Map .of ("method" , "GET " , "exception" , e .getMessage ())));
204+ connectLib .Logger ().CRITICAL (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "general.error" , Map .of ("method" , "PUT " , "exception" , e .getMessage ())));
179205 }
180206 })
181207 .map (responseData -> {
@@ -190,13 +216,16 @@ record ResponseData(int statusCode, String body) {}
190216 /**
191217 * Method to call the API with a PATCH request.
192218 * @param routeName Name of the route to call.
193- * @param body Body of the request (can be null for a request without body).
219+ * @param body Body of the request (can be null for a request without body).
194220 * @return a Mono that emits the ApiFactory response containing the parsed JSON data.
195221 */
196222 public Mono <ApiFactory > callAPIPatch (String routeName , Map <String , Object > body ) {
197223 connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.patch" , Map .of ("routename" , routeName )));
198224
199- Request r = DataController .getInstance ().createRequest (routeName , baseUrl );
225+ AtomicReference <Request > requestRef = new AtomicReference <>();
226+ if (connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().IS_APP_RUNNING ).equals (true )) {
227+ requestRef .set (DataController .getInstance ().createRequest (routeName , baseUrl ));
228+ }
200229
201230 record ResponseData (int statusCode , String body ) {}
202231
@@ -213,9 +242,14 @@ record ResponseData(int statusCode, String body) {}
213242
214243 String newStatus = (responseData .statusCode () >= 200 && responseData .statusCode () < 300 ) ? "success" : "error" ;
215244 try {
216- DataController .getInstance ().updateRequestStatus (r .getId (), newStatus );
245+ if (connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().IS_APP_RUNNING ).equals (true )) {
246+ Request r = requestRef .get ();
247+ if (r != null ) {
248+ DataController .getInstance ().updateRequestStatus (r .getId (), newStatus );
249+ }
250+ }
217251 } catch (Exception e ) {
218- connectLib .Logger ().CRITICAL (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "general.error" , Map .of ("method" , "GET " , "exception" , e .getMessage ())));
252+ connectLib .Logger ().CRITICAL (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "general.error" , Map .of ("method" , "PATCH " , "exception" , e .getMessage ())));
219253 }
220254 })
221255 .map (responseData -> {
@@ -235,7 +269,10 @@ record ResponseData(int statusCode, String body) {}
235269 public Mono <ApiFactory > callAPIDelete (String routeName ) {
236270 connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.delete" , Map .of ("routename" , routeName )));
237271
238- Request r = DataController .getInstance ().createRequest (routeName , baseUrl );
272+ AtomicReference <Request > requestRef = new AtomicReference <>();
273+ if (connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().IS_APP_RUNNING ).equals (true )) {
274+ requestRef .set (DataController .getInstance ().createRequest (routeName , baseUrl ));
275+ }
239276
240277 record ResponseData (int statusCode , String body ) {}
241278
@@ -251,9 +288,14 @@ record ResponseData(int statusCode, String body) {}
251288
252289 String newStatus = (responseData .statusCode () >= 200 && responseData .statusCode () < 300 ) ? "success" : "error" ;
253290 try {
254- DataController .getInstance ().updateRequestStatus (r .getId (), newStatus );
291+ if (connectLib .StoreAndRetrieve ().get (connectLib .StoreAndRetrieve ().IS_APP_RUNNING ).equals (true )) {
292+ Request r = requestRef .get ();
293+ if (r != null ) {
294+ DataController .getInstance ().updateRequestStatus (r .getId (), newStatus );
295+ }
296+ }
255297 } catch (Exception e ) {
256- connectLib .Logger ().CRITICAL (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "general.error" , Map .of ("method" , "GET " , "exception" , e .getMessage ())));
298+ connectLib .Logger ().CRITICAL (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "general.error" , Map .of ("method" , "DELETE " , "exception" , e .getMessage ())));
257299 }
258300 })
259301 .map (responseData -> {
0 commit comments