This is a design question. I need some suggestion on how to structure a PHP module to consume an API service, with this features:
- The API has 2 separate hosts for 2 different versions (V1 and V2)
- the 2 APIs uses different endpoints
- the 2 APIs returns the same data in JSON but structured differently
what I thought I could do is:
- a base abstract class called Client that load parameters and uses Guzzle to perform the call
- a ClientV2 class that extends Client, with methods like getServices, addService, ect...
- a ClientV1 class similar to ClientV2, V1 is going to be deprecated so I just need a few methods here
the idea would be to make this flexible enough if I will need to work on V3.
and how to manage the fact the the different APIs return different data? I know how to implement guzzle. What I am looking for is a design pattern to structure this and an understanding on what classes I am going to need.
thanks
Aucun commentaire:
Enregistrer un commentaire