I am creating a API to create Personnels of X city. Assume that there is a generalised service for creating personnel of any city and I want to call this service for X city personnels from my API.
While implementing my API, I am planning to do following:
- Validate the input parameters and business logic validation which is specific to X city personnels.
- If Validation of the input parameters fails, API will throw 400 with error message
- Call the Generic Personnel Service with the input and create the Personnel.
- If call passes, create the entry in my datastore for this personnel. And return 200.
- If call fails, create the entry in my datastore for this personnel with the error message. And return 400 with the error message.
Following are my doubts in above flow:
- In Point 5 that whether it is a good design/pattern to store the failure in datastore or not. One of the reason to store it is to show the users these failures later and so that they know it failed because of this reason.
- What type of service my service will be called? Is there any design pattern that this kind of service should follow?
- Should I be storing the entity for personnels created by my service at my end or not?