I need to call two APIs A1 and A2 but not parallelly. A2 would get called only if A1 returns some flag value in its JSON response.
I'm aware of how to make an http call in java using Httpclient. one way is to write one code to make first call and parse its response and again use the same code to make another call.Is their any other smart way which automate this process for us where I will pass both the request and the condition on which second one need to call like it is possible in Rxjava
Follwing is the Rxjava code snippet (Reference : (RxJava Combine Sequence Of Requests))
api1.items(queryParam)
.flatMap(itemList -> Observable.fromIterable(itemList)))
.flatMap(item -> api2.extendedInfo(item.id()))
.subscribe(...)
How can I accomplish this in Java? Is there any Java feature that already exists and will allow me to make a multiple sequential call?
I tried searching for existing solutions but they were not in Java.