26 lines
796 B
Python
26 lines
796 B
Python
import json
|
|
import requests
|
|
from abc import ABC
|
|
|
|
class Base(ABC):
|
|
def __init__(self, api_token:str, clan_tag:str = None) -> None:
|
|
self.headers = {
|
|
"Content-Type": "application/json",
|
|
"Authorization": "Bearer {api_token}".format(api_token=api_token)
|
|
}
|
|
self.clan_tag = clan_tag
|
|
|
|
def get(self, url: str, tag: str):
|
|
request = requests.get(
|
|
url.format(tag.replace("#", "")),
|
|
headers=self.headers
|
|
)
|
|
return json.loads(request.text)
|
|
|
|
def post(self, url: str, tag: str, payload: dict):
|
|
request = requests.post(
|
|
url=url.format(tag.replace("#", "")),
|
|
headers=self.headers,
|
|
data=json.dumps(payload)
|
|
)
|
|
return json.loads(request.text) |