first
This commit is contained in:
74
entities/PiapiTask.py
Normal file
74
entities/PiapiTask.py
Normal file
@ -0,0 +1,74 @@
|
||||
from igf_api.BaseEntity import BaseEntity
|
||||
|
||||
|
||||
class PiapiTask(BaseEntity):
|
||||
|
||||
def get_list(self):
|
||||
return self.connection.raw_request(method='get', endpoint='/piapi')
|
||||
|
||||
def get_one(self, data):
|
||||
schema = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'bot_id': {'type': 'integer'},
|
||||
'dialog_id': {'type': 'integer'},
|
||||
'task_id': {"type": ["string", "null"]},
|
||||
'model': {'type': 'string'},
|
||||
'task_type': {'type': 'string'},
|
||||
'prompt': {'type': 'string'},
|
||||
'status': {'type': 'integer'},
|
||||
},
|
||||
'required': []
|
||||
}
|
||||
|
||||
if self.validate_dict(data, schema):
|
||||
return self.connection.raw_request('get', '/piapi/get-one', params=data)
|
||||
|
||||
return False
|
||||
|
||||
def create(self, data):
|
||||
schema = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'bot_id': {'type': 'integer'},
|
||||
'dialog_id': {'type': 'integer'},
|
||||
'task_id': {"type": ["string", "null"]},
|
||||
'model': {'type': 'string'},
|
||||
'task_type': {'type': 'string'},
|
||||
'prompt': {'type': 'string'},
|
||||
'status': {'type': 'integer'},
|
||||
},
|
||||
'required': ['dialog_id', 'bot_id']
|
||||
}
|
||||
|
||||
if self.validate_dict(data, schema):
|
||||
return self.connection.raw_request('post', '/piapi', data=data)
|
||||
|
||||
return False
|
||||
|
||||
def update(self, id: int, data):
|
||||
schema = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'bot_id': {'type': 'integer'},
|
||||
'dialog_id': {'type': 'integer'},
|
||||
'task_id': {"type": ["string", "null"]},
|
||||
'model': {'type': 'string'},
|
||||
'task_type': {'type': 'string'},
|
||||
'prompt': {'type': 'string'},
|
||||
'status': {'type': 'integer'},
|
||||
},
|
||||
'required': []
|
||||
}
|
||||
|
||||
if self.validate_dict(data, schema):
|
||||
return self.connection.raw_request('post', '/piapi/update/{id}'.format(id=id), data=data)
|
||||
|
||||
return False
|
||||
|
||||
def to_archive_all_new(self, bot_id: int, dialog_id: int):
|
||||
return self.connection.raw_request('get', '/piapi/to-archive-all-new/{bot_id}/{dialog_id}'.format(bot_id=bot_id,
|
||||
dialog_id=dialog_id))
|
||||
|
||||
def get_new_tasks(self):
|
||||
return self.connection.raw_request('get', '/piapi/find?status={status}'.format(status=1))
|
26
entities/TgBot.py
Normal file
26
entities/TgBot.py
Normal file
@ -0,0 +1,26 @@
|
||||
from igf_api.BaseEntity import BaseEntity
|
||||
|
||||
|
||||
class TgBot(BaseEntity):
|
||||
|
||||
def get_list(self):
|
||||
return self.connection.raw_request(method='get', endpoint='/tg-bot')
|
||||
|
||||
def create(self, data):
|
||||
schema = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'bot_id': {'type': 'integer'},
|
||||
'dialog_id': {'type': 'integer'},
|
||||
'username': {'type': 'string'},
|
||||
'first_name': {'type': 'string'},
|
||||
'last_name': {'type': 'string'},
|
||||
'status': {'type': 'integer'},
|
||||
},
|
||||
'required': ['dialog_id', 'bot_id']
|
||||
}
|
||||
|
||||
if self.validate_dict(data, schema):
|
||||
return self.connection.raw_request('post', '/tg-bot', data=data)
|
||||
|
||||
return False
|
Reference in New Issue
Block a user