diff options
| author | DavidRThrashJr <60800614+DavidRThrashJr@users.noreply.github.com> | 2020-02-20 03:35:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-20 09:35:03 +0100 |
| commit | 72653c0d3ac5ea5265479e7e53ff39cfe62a00ce (patch) | |
| tree | cc303e2fdd681ab3c9914716443c6fad392ca55f /ihatemoney/api/v1 | |
| parent | 32d76178c0ebe05bddb596f85b283f3f0ee74c85 (diff) | |
| download | ihatemoney-mirror-72653c0d3ac5ea5265479e7e53ff39cfe62a00ce.zip ihatemoney-mirror-72653c0d3ac5ea5265479e7e53ff39cfe62a00ce.tar.gz ihatemoney-mirror-72653c0d3ac5ea5265479e7e53ff39cfe62a00ce.tar.bz2 | |
Added support for multiple API versions (#533)
* Added support for multiple API versions
Note that no changes were made to the api, the code was refactored to allow for new versions of the api to be created down the road.
Here's what this would look like:
+-- api/
+-- v1/
+-- __init__.py
+-- resources.py
+-- v1_1/
+-- __init__.py
+-- resources.py
+-- v2/
+-- __init__.py
+-- resources.py
+-- __init__.py
+-- common.py
* reformatted using black
/Users/drthrash/PycharmProjects/ihatemoney/ihatemoney/api/v1/resources.py
reformatted /Users/drthrash/PycharmProjects/ihatemoney/ihatemoney/api/common.py
All done! ✨ 🍰 ✨
* Applying fix for unused import in init.py
https://stackoverflow.com/questions/31079047/python-pep8-class-in-init-imported-but-not-used
* Formatting changes recommended by black
All done! ✨ 🍰 ✨
1 file reformatted, 22 files left unchanged.
Diffstat (limited to 'ihatemoney/api/v1')
| -rw-r--r-- | ihatemoney/api/v1/__init__.py | 5 | ||||
| -rw-r--r-- | ihatemoney/api/v1/resources.py | 34 |
2 files changed, 39 insertions, 0 deletions
diff --git a/ihatemoney/api/v1/__init__.py b/ihatemoney/api/v1/__init__.py new file mode 100644 index 0000000..11afff7 --- /dev/null +++ b/ihatemoney/api/v1/__init__.py @@ -0,0 +1,5 @@ +from .resources import api + +__all__ = [ + "api", +] diff --git a/ihatemoney/api/v1/resources.py b/ihatemoney/api/v1/resources.py new file mode 100644 index 0000000..821ba2b --- /dev/null +++ b/ihatemoney/api/v1/resources.py @@ -0,0 +1,34 @@ +# coding: utf8 +from flask import Blueprint +from flask_restful import Api +from flask_cors import CORS + +from ihatemoney.api.common import ( + ProjectsHandler, + ProjectHandler, + TokenHandler, + MemberHandler, + ProjectStatsHandler, + MembersHandler, + BillHandler, + BillsHandler, +) + +api = Blueprint("api", __name__, url_prefix="/api") +CORS(api) +restful_api = Api(api) + +restful_api.add_resource(ProjectsHandler, "/projects") +restful_api.add_resource(ProjectHandler, "/projects/<string:project_id>") +restful_api.add_resource(TokenHandler, "/projects/<string:project_id>/token") +restful_api.add_resource(MembersHandler, "/projects/<string:project_id>/members") +restful_api.add_resource( + ProjectStatsHandler, "/projects/<string:project_id>/statistics" +) +restful_api.add_resource( + MemberHandler, "/projects/<string:project_id>/members/<int:member_id>" +) +restful_api.add_resource(BillsHandler, "/projects/<string:project_id>/bills") +restful_api.add_resource( + BillHandler, "/projects/<string:project_id>/bills/<int:bill_id>" +) |
