Browse Source

Add middleware and start of proper wrapper

JoostSijm 4 years ago
parent
commit
6aa98c296d

+ 10 - 0
__init__.py

@@ -0,0 +1,10 @@
+
+"""
+Rival Regions Wrapper
+
+This unofficial API wrapper is an implementation
+of some Rival Regions functionalities.
+"""
+
+from authentication_handler.authentication_handler import AuthenticationHandler
+from middleware.middleware import LocalAuthentication, RemoteAuthentication

+ 1 - 0
api_wrapper/__init__.py

@@ -0,0 +1 @@
+"""API wrapper for Rival Regions"""

+ 1 - 1
rival_regions_wrapper/client.py → authentication_handler/authentication_handler.py

@@ -85,7 +85,7 @@ def session_handler(func):
 
     return wrapper
 
-class Client:
+class AuthenticationHandler:
     """class for RR client"""
     cookie = None
     var_c = None

+ 48 - 0
middleware/middleware.py

@@ -0,0 +1,48 @@
+"""middleware class"""
+
+from abc import ABC, abstractmethod
+
+from authentication_handler import AuthenticationHandeler
+
+
+class MiddlewareBase(ABC):
+    """Middleware abstract base class"""
+
+    @abstractmethod
+    def get(self, path, add_c_var=False):
+        """Send get request"""
+
+    @abstractmethod
+    def post(self, path, data=None):
+        """Send post request"""
+
+
+class LocalAuthentication(MiddlewareBase):
+    """Local authentication"""
+
+    def __init__(self, username, password, login_method):
+        self.username = username
+        self.password = password
+        self.login_method = login_method
+        super().__init__()
+
+    def get(self, path, add_c_var=False):
+        """Send get requests"""
+
+    def post(self, path, data=None):
+        """Send post request"""
+
+
+class RemoteAuthentication(MiddlewareBase):
+    """Remote authentication"""
+
+    def __init__(self, api_url, authentication_key):
+        self.api_url = api_url
+        self.authentication_key = authentication_key
+        super().__init__()
+
+    def get(self, path, add_c_var=False):
+        """Send get requests"""
+
+    def post(self, path, data=None):
+        """Send post request"""

+ 0 - 9
rival_regions_wrapper/__init__.py

@@ -1,9 +0,0 @@
-
-"""
-Rival Regions Wrapper
-
-This unofficial API wrapper is an implementation
-of some Rival Regions functionalities.
-"""
-
-from .client import Client