Skip to content

Conversation

@bjy19
Copy link

@bjy19 bjy19 commented Aug 11, 2021

Why I used it.
In this API there are three different classes called csbc.py, jhu.py, and nyt.py from where we get all data. Here we need to call 3 different types of methods for getting same data. That's why I created an adapter that provides data from the appropriate source with one single method.

How I made it.
In the services/location/__init__.py file I made an adapter class called LocationService. This class provides two common methods for any type of source. The name of these methods are get_all() and get(). I am storing the object of adapter classes inside the request.state.source. Hence when we call it from router v2.py then we only need to watch the methods of the adapter.

@Kilo59 Kilo59 closed this Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants