11package fr .sandro642 .github .api ;
22
33import fr .sandro642 .github .ConnectLib ;
4+ import fr .sandro642 .github .enums .lang .CategoriesType ;
45import fr .sandro642 .github .misc .Logger ;
56import org .springframework .web .reactive .function .client .WebClient ;
67import reactor .core .publisher .Mono ;
@@ -54,7 +55,7 @@ public ApiClient() {
5455 String baseUrl = (String ) ConnectLib .StoreAndRetrieve ().store .get (ConnectLib .StoreAndRetrieve ().URL_KEY );
5556
5657 if (baseUrl == null ) {
57- logger .CRITICAL ("Base URL not found in configuration. Please set the base URL in the configuration file." );
58+ logger .CRITICAL (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "construct.urlbase" ) );
5859 }
5960
6061 this .webClient = WebClient .builder ()
@@ -68,20 +69,20 @@ public ApiClient() {
6869 * @return a Mono that emits the ApiFactory response containing the parsed JSON data.
6970 */
7071 public Mono <ApiFactory > callAPIGet (String routeName ) {
71- logger .INFO ("Call GET to : " + routeName );
72+ logger .INFO (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "call.get" , Map . of ( "routename" , routeName )) );
7273 return webClient .get ()
7374 .uri (routeName )
7475 .retrieve ()
7576 .bodyToMono (String .class )
7677 .subscribeOn (Schedulers .boundedElastic ())
7778 .doOnNext (thread ->
78- ConnectLib .Logger ().INFO ("Current thread in use: " + Thread .currentThread ().getName ()))
79+ ConnectLib .Logger ().INFO (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "call.threadinuse" , " thread" , Thread .currentThread ().getName () )))
7980 .map (rawJson -> {
8081 response .parseFromRawJson (rawJson );
8182 return response ;
8283 })
8384 .doOnNext (lastResponse ::set )
84- .doOnError (error -> logger .CRITICAL ("Error while call GET: " + error .getMessage ()));
85+ .doOnError (error -> logger .CRITICAL (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "general.error" , Map . of ( "method" , " GET" , "exception" , error .getMessage ()) )));
8586 }
8687
8788 /**
@@ -91,21 +92,21 @@ public Mono<ApiFactory> callAPIGet(String routeName) {
9192 * @return a Mono that emits the ApiFactory response containing the parsed JSON data.
9293 */
9394 public Mono <ApiFactory > callAPIPost (String routeName , Map <String , Object > body ) {
94- logger .INFO ("Call POST to : " + routeName );
95+ logger .INFO (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "call.post" , Map . of ( "routename" , routeName )) );
9596 return webClient .post ()
9697 .uri (routeName )
9798 .bodyValue (body != null ? body : Map .of ())
9899 .retrieve ()
99100 .bodyToMono (String .class )
100101 .subscribeOn (Schedulers .boundedElastic ())
101102 .doOnNext (thread ->
102- ConnectLib .Logger ().INFO ("Thread en cours d'utilisation: " + Thread .currentThread ().getName ()))
103+ ConnectLib .Logger ().INFO (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName () )))
103104 .map (rawJson -> {
104105 response .parseFromRawJson (rawJson );
105106 return response ;
106107 })
107108 .doOnNext (lastResponse ::set )
108- .doOnError (error -> logger .CRITICAL ("Error while call POST: " + error .getMessage ()));
109+ .doOnError (error -> logger .CRITICAL (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "general.error" , Map . of ( "method" , " POST" , "exception" , error .getMessage ()) )));
109110 }
110111
111112 /**
@@ -115,21 +116,21 @@ public Mono<ApiFactory> callAPIPost(String routeName, Map<String, Object> body)
115116 * @return a Mono that emits the ApiFactory response containing the parsed JSON data.
116117 */
117118 public Mono <ApiFactory > callAPIPut (String routeName , Map <String , Object > body ) {
118- logger .INFO ("Call PUT to : " + routeName );
119+ logger .INFO (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "call.put" , Map . of ( "routename" , routeName )) );
119120 return webClient .put ()
120121 .uri (routeName )
121122 .bodyValue (body != null ? body : Map .of ())
122123 .retrieve ()
123124 .bodyToMono (String .class )
124125 .subscribeOn (Schedulers .boundedElastic ())
125126 .doOnNext (thread ->
126- ConnectLib .Logger ().INFO ("Thread en cours d'utilisation: " + Thread .currentThread ().getName ()))
127+ ConnectLib .Logger ().INFO (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName () )))
127128 .map (rawJson -> {
128129 response .parseFromRawJson (rawJson );
129130 return response ;
130131 })
131132 .doOnNext (lastResponse ::set )
132- .doOnError (error -> logger .CRITICAL ("Error while call PUT: " + error .getMessage ()));
133+ .doOnError (error -> logger .CRITICAL (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "general.error" , Map . of ( "method" , " PUT" , "exception" , error .getMessage ()) )));
133134 }
134135
135136 /**
@@ -139,21 +140,21 @@ public Mono<ApiFactory> callAPIPut(String routeName, Map<String, Object> body) {
139140 * @return a Mono that emits the ApiFactory response containing the parsed JSON data.
140141 */
141142 public Mono <ApiFactory > callAPIPatch (String routeName , Map <String , Object > body ) {
142- logger .INFO ("Call PATCH to : " + routeName );
143+ logger .INFO (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "call.patch" , Map . of ( "routename" , routeName )) );
143144 return webClient .patch ()
144145 .uri (routeName )
145146 .bodyValue (body != null ? body : Map .of ())
146147 .retrieve ()
147148 .bodyToMono (String .class )
148149 .subscribeOn (Schedulers .boundedElastic ())
149150 .doOnNext (thread ->
150- ConnectLib .Logger ().INFO ("Thread en cours d'utilisation: " + Thread .currentThread ().getName ()))
151+ ConnectLib .Logger ().INFO (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName () )))
151152 .map (rawJson -> {
152153 response .parseFromRawJson (rawJson );
153154 return response ;
154155 })
155156 .doOnNext (lastResponse ::set )
156- .doOnError (error -> logger .CRITICAL ("Error while call PATCH: " + error .getMessage ()));
157+ .doOnError (error -> logger .CRITICAL (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "general.error" , Map . of ( "method" , " PATCH" , "exception" , error .getMessage ()) )));
157158 }
158159
159160 /**
@@ -162,19 +163,19 @@ public Mono<ApiFactory> callAPIPatch(String routeName, Map<String, Object> body)
162163 * @return a Mono that emits the ApiFactory response containing the parsed JSON data.
163164 */
164165 public Mono <ApiFactory > callAPIDelete (String routeName ) {
165- logger .INFO ("Call DELETE to : " + routeName );
166+ logger .INFO (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "call.delete" , Map . of ( "routename" , routeName )) );
166167 return webClient .delete ()
167168 .uri (routeName )
168169 .retrieve ()
169170 .bodyToMono (String .class )
170171 .subscribeOn (Schedulers .boundedElastic ())
171172 .doOnNext (thread ->
172- ConnectLib .Logger ().INFO ("Thread en cours d'utilisation: " + Thread .currentThread ().getName ()))
173+ ConnectLib .Logger ().INFO (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName () )))
173174 .map (rawJson -> {
174175 response .parseFromRawJson (rawJson );
175176 return response ;
176177 })
177178 .doOnNext (lastResponse ::set )
178- .doOnError (error -> logger .CRITICAL ("Error while call DELETE: " + error .getMessage ()));
179+ .doOnError (error -> logger .CRITICAL (ConnectLib . LangManager (). getMessage ( CategoriesType . APICLIENT_CLASS , "general.error" , Map . of ( "method" , " DELETE" , "exception" , error .getMessage ()) )));
179180 }
180181}
0 commit comments