mirror of
https://github.com/MrSedan/neuro-reply-bot-reworked.git
synced 2026-01-15 05:59:43 +03:00
added proxyapi
This commit is contained in:
30
proxyapi/_methods/operation.py
Normal file
30
proxyapi/_methods/operation.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from aiohttp import ClientSession
|
||||
|
||||
import proxyapi.types as proxyTypes
|
||||
|
||||
from neuroapi._methods.api_method import ApiMethod
|
||||
|
||||
|
||||
class Operation(ApiMethod):
|
||||
|
||||
async def add(self, user_name: str):
|
||||
payload = {'userName': user_name}
|
||||
async with ClientSession() as session:
|
||||
response = await session.post(
|
||||
self.api_url+'/proxy/operation/add', data=payload)
|
||||
data = await response.json()
|
||||
if 'statusCode' in data:
|
||||
raise Exception(data['message'])
|
||||
return proxyTypes.Operation.from_dict(data)
|
||||
|
||||
async def get(self, user_name: str):
|
||||
async with ClientSession() as session:
|
||||
response = await session.get(
|
||||
self.api_url + f'/proxy/operation/get/{user_name}')
|
||||
return [proxyTypes.Operation.from_dict(data) for data in await response.json()]
|
||||
|
||||
async def get_all(self):
|
||||
async with ClientSession() as session:
|
||||
response = await session.get(
|
||||
self.api_url + f'/proxy/operation/get-all')
|
||||
return [proxyTypes.Operation.from_dict(data) for data in await response.json()]
|
||||
31
proxyapi/_methods/user.py
Normal file
31
proxyapi/_methods/user.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from aiohttp import ClientSession
|
||||
|
||||
import proxyapi.types as proxyTypes
|
||||
|
||||
from neuroapi._methods.api_method import ApiMethod
|
||||
|
||||
|
||||
class User(ApiMethod):
|
||||
|
||||
async def new_user(self, user_name: str, description: str, link: str, user_id: str):
|
||||
payload = {'userName': user_name, 'description': description,
|
||||
'link': link, 'user_id': user_id}
|
||||
async with ClientSession() as session:
|
||||
response = await session.post(self.api_url+'/proxy/new-user', data=payload)
|
||||
data = await response.json()
|
||||
if 'statusCode' in data:
|
||||
raise Exception(data['message'])
|
||||
return proxyTypes.User.from_dict(data)
|
||||
|
||||
async def get_user(self, user_name: str):
|
||||
async with ClientSession() as session:
|
||||
response = await session.get(self.api_url+f'/proxy/get-user/{user_name}')
|
||||
data = await response.json()
|
||||
if 'statusCode' in data:
|
||||
raise Exception(data['message'])
|
||||
return proxyTypes.User.from_dict(data)
|
||||
|
||||
async def get_all_users(self):
|
||||
async with ClientSession() as session:
|
||||
response = await session.get(self.api_url+'/proxy/get-all-users')
|
||||
return [proxyTypes.User.from_dict(data) for data in await response.json()]
|
||||
Reference in New Issue
Block a user