@@ -68,15 +68,22 @@ public ApiClient() {
6868 */
6969 public Mono <ApiFactory > callAPIGet (String routeName ) {
7070 connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.get" , Map .of ("routename" , routeName )));
71+
72+ record ResponseData (int statusCode , String body ) {}
73+
7174 return webClient .get ()
7275 .uri (routeName )
73- .retrieve ()
74- .bodyToMono (String .class )
76+ .exchangeToMono (response ->
77+ response .bodyToMono (String .class )
78+ .map (rawJson -> new ResponseData (response .statusCode ().value (), rawJson ))
79+ )
7580 .subscribeOn (Schedulers .boundedElastic ())
76- .doOnNext (thread ->
77- connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName ())))
78- .map (rawJson -> {
79- apiFactory .parseFromRawJson (rawJson );
81+ .doOnNext (responseData -> {
82+ connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName ()));
83+ })
84+ .map (responseData -> {
85+ apiFactory .setStatusCode (responseData .statusCode ());
86+ apiFactory .parseFromRawJson (responseData .body );
8087 return apiFactory ;
8188 })
8289 .doOnNext (lastResponse ::set )
@@ -91,16 +98,23 @@ public Mono<ApiFactory> callAPIGet(String routeName) {
9198 */
9299 public Mono <ApiFactory > callAPIPost (String routeName , Map <String , Object > body ) {
93100 connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.post" , Map .of ("routename" , routeName )));
101+
102+ record ResponseData (int statusCode , String body ) {}
103+
94104 return webClient .post ()
95105 .uri (routeName )
96106 .bodyValue (body != null ? body : Map .of ())
97- .retrieve ()
98- .bodyToMono (String .class )
107+ .exchangeToMono (response ->
108+ response .bodyToMono (String .class )
109+ .map (rawJson -> new ResponseData (response .statusCode ().value (), rawJson ))
110+ )
99111 .subscribeOn (Schedulers .boundedElastic ())
100- .doOnNext (thread ->
101- connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName ())))
102- .map (rawJson -> {
103- apiFactory .parseFromRawJson (rawJson );
112+ .doOnNext (responseData -> {
113+ connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName ()));
114+ })
115+ .map (responseData -> {
116+ apiFactory .setStatusCode (responseData .statusCode ());
117+ apiFactory .parseFromRawJson (responseData .body ());
104118 return apiFactory ;
105119 })
106120 .doOnNext (lastResponse ::set )
@@ -115,16 +129,23 @@ public Mono<ApiFactory> callAPIPost(String routeName, Map<String, Object> body)
115129 */
116130 public Mono <ApiFactory > callAPIPut (String routeName , Map <String , Object > body ) {
117131 connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.put" , Map .of ("routename" , routeName )));
132+
133+ record ResponseData (int statusCode , String body ) {}
134+
118135 return webClient .put ()
119136 .uri (routeName )
120137 .bodyValue (body != null ? body : Map .of ())
121- .retrieve ()
122- .bodyToMono (String .class )
138+ .exchangeToMono (response ->
139+ response .bodyToMono (String .class )
140+ .map (rawJson -> new ResponseData (response .statusCode ().value (), rawJson ))
141+ )
123142 .subscribeOn (Schedulers .boundedElastic ())
124- .doOnNext (thread ->
125- connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName ())))
126- .map (rawJson -> {
127- apiFactory .parseFromRawJson (rawJson );
143+ .doOnNext (responseData -> {
144+ connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName ()));
145+ })
146+ .map (responseData -> {
147+ apiFactory .setStatusCode (responseData .statusCode ());
148+ apiFactory .parseFromRawJson (responseData .body ());
128149 return apiFactory ;
129150 })
130151 .doOnNext (lastResponse ::set )
@@ -139,16 +160,23 @@ public Mono<ApiFactory> callAPIPut(String routeName, Map<String, Object> body) {
139160 */
140161 public Mono <ApiFactory > callAPIPatch (String routeName , Map <String , Object > body ) {
141162 connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.patch" , Map .of ("routename" , routeName )));
163+
164+ record ResponseData (int statusCode , String body ) {}
165+
142166 return webClient .patch ()
143167 .uri (routeName )
144168 .bodyValue (body != null ? body : Map .of ())
145- .retrieve ()
146- .bodyToMono (String .class )
169+ .exchangeToMono (response ->
170+ response .bodyToMono (String .class )
171+ .map (rawJson -> new ResponseData (response .statusCode ().value (), rawJson ))
172+ )
147173 .subscribeOn (Schedulers .boundedElastic ())
148- .doOnNext (thread ->
149- connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName ())))
150- .map (rawJson -> {
151- apiFactory .parseFromRawJson (rawJson );
174+ .doOnNext (responseData -> {
175+ connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName ()));
176+ })
177+ .map (responseData -> {
178+ apiFactory .setStatusCode (responseData .statusCode ());
179+ apiFactory .parseFromRawJson (responseData .body ());
152180 return apiFactory ;
153181 })
154182 .doOnNext (lastResponse ::set )
@@ -162,15 +190,22 @@ public Mono<ApiFactory> callAPIPatch(String routeName, Map<String, Object> body)
162190 */
163191 public Mono <ApiFactory > callAPIDelete (String routeName ) {
164192 connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.delete" , Map .of ("routename" , routeName )));
193+
194+ record ResponseData (int statusCode , String body ) {}
195+
165196 return webClient .delete ()
166197 .uri (routeName )
167- .retrieve ()
168- .bodyToMono (String .class )
198+ .exchangeToMono (response ->
199+ response .bodyToMono (String .class )
200+ .map (rawJson -> new ResponseData (response .statusCode ().value (), rawJson ))
201+ )
169202 .subscribeOn (Schedulers .boundedElastic ())
170- .doOnNext (thread ->
171- connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName ())))
172- .map (rawJson -> {
173- apiFactory .parseFromRawJson (rawJson );
203+ .doOnNext (responseData -> {
204+ connectLib .Logger ().INFO (connectLib .LangManager ().getMessage (CategoriesType .APICLIENT_CLASS , "call.threadinuse" , "thread" , Thread .currentThread ().getName ()));
205+ })
206+ .map (responseData -> {
207+ apiFactory .setStatusCode (responseData .statusCode ());
208+ apiFactory .parseFromRawJson (responseData .body ());
174209 return apiFactory ;
175210 })
176211 .doOnNext (lastResponse ::set )
0 commit comments