Hello, I need to instantiate a class according to the parameter received by a webhook , does anyone have any idea how to do it?
It would be more or less this (some scenarios):
Customer
{"id":"1"}
ClienteDao
who implements a collector interface with a collection method. ClienteDao
) and calls the collection method, which queries the database and makes the parser for JSON. Product
{"id":"2"}
ProdutoDao
who implements a collector interface with a collection method. ProdutoDao
) and calls the collection method, which queries the database and makes the parser for JSON. Cart
{"id":"3"}
CarrinhoDao
who implements a collector interface with a collection method. CarrinhoDao
) and calls the collection method, which queries the database and makes the parser for JSON. Solutions excluded:
if
- > procedural I'm looking for an elegant solution and that in the future I will not have headache to maintain.