jeudi 6 octobre 2022

What design pattern can be followed while implementing API that calls multiple APIs

I have just begun exploring the design patterns and implementation of Web APIs.

I have a scenario where one single API requests to a set of APIs in sequence based on a string value.

Eg: let's say I have an API called StartAPI. This might send request to a subset of APIs (let's call it API_X, API_Y, API_Z, API_T, API_U) based on given string.

Let's assume the below: If i pass "string1" or "string2" to StartAPI then it should call API_X, API_Z.

If i pass "string3" it calls API_X, API_Z, API_T.

If i pass "string4" it calls all APIs

API_X, API_Z, API_T, API_Y, API_U.

What design pattern can I follow in this case to minimise the if else conditions?

Aucun commentaire:

Enregistrer un commentaire