nat236919 / covid19-api

API for exploring COVID-19 cases around the globe
https://nuttaphat.com/covid19-api/
MIT License
119 stars 63 forks source link

Structural pattern #223

Closed lxy1819 closed 3 years ago

lxy1819 commented 3 years ago

Related Issue:

As I noticed that the API has two versions, and those two versions have different methods, Some users might be interested in some methods in v1 and some other methods in v2. Thus, I applied an adapter pattern to make the API project more flexible and reusable. In this way, the users can modify Adapter.py to create their version of API, and it helps the users add new functions quickly.

Proposed Changes

  1. Adding a new class Adapter to apply an adapter pattern and Adapter will help the users to assign different methods in the integrator files to the router files.

  2. Changing data structure in the router files. Before, the constructors in router files called the methods in the integrator files to get the data. After the changes, the adapter class calls the integrator files' methods first and then assigns the data to the constructors in the router files.

Addtional Info

It seems the test files are modified as well after I made the changes to the router files. I am not a python programming pro, so I do not know how to fix those test files, but I think this pull request can show you my general idea about applying an adapter pattern to the project.

Checklist