from flask_restplus import fields from app.apis import api new_message = api.model( 'New Message', { 'domain': fields.String(default='', required=False, min_length=0, max_length=16), 'type': fields.String(default='', required=False, min_length=0, max_length=24), 'content': fields.String(required=True, min_length=1, max_length=64 * 1024), }) sync_msg_id = api.model('Sync Msg ID', { 'msg_id': fields.Integer(required=True, min=0), })
description='project xchat chat id'), }) new_channel_message = api.model( 'New Channel Message', { 'channel': fields.String(required=True, enum=('wechat', )), 'project_domain': fields.String(required=False), 'project_type': fields.String(required=False), 'project_biz_id': fields.String(required=False), 'biz_id': fields.String(required=False, description='alias for project_biz_id'), 'project_id': fields.Integer(required=False), 'id': fields.Integer(required=False, description='alias for project_id'), 'uid': fields.String(required=True), 'domain': fields.String(required=False), 'type': fields.String(required=True, enum=('text', 'file', 'image', 'voice')), 'content': any_of(['string', 'object'], required=True) }) project_state_info = api.model( 'Project State Info', {
from flask_restplus import fields from app.apis import api from app.apis.serializers import pagination, base_resource _raw_bucket_specs = { 'name': fields.String(required=True, min_length=1, description='bucket name') } raw_bucket = api.model('Raw Bucket', _raw_bucket_specs) bucket = api.inherit('Bucket', base_resource, _raw_bucket_specs) page_of_buckets = api.inherit('Page of buckets', pagination, { 'items': fields.List(fields.Nested(bucket)) })
from flask_restplus import fields from app.apis import api app_auth_data = api.model('App auth data', { 'app_name': fields.String(required=True, min_length=1, example='test', description='app name'), 'app_password': fields.String(required=True, min_length=1, example='test1234', description='app password') }) customer_auth_data = api.inherit('Customer auth data', app_auth_data, { 'uid': fields.String(required=True, min_length=1, example='test', description='customer uid') }) staff_auth_data = api.inherit('Staff auth data', app_auth_data, { 'uid': fields.String(required=True, min_length=1, example='test', description='staff uid') }) app_change_password_data = api.inherit('App change password data', app_auth_data, { 'new_password': fields.String(required=True, min_length=1, description='new password') })
from flask_restplus import fields from app.apis import api from app.apis.serializers.app import application from app.apis.serializers.xfields import any_of from .staff import staff_data staff_app_info = api.model('Staff App Info', { 'staff': fields.Nested(staff_data), 'app': fields.Nested(application), 'project_domains': any_of(['array']), 'staffs': fields.List(fields.Nested(staff_data)) })
from flask_restplus import fields from app.apis import api from app.apis.serializers import pagination from app.apis.serializers.xfields import any_of staff_data = api.model('Staff Data', { 'uid': fields.String(), 'name': fields.String(), 'context_labels': any_of(['array']), 'is_online': fields.Boolean(), 'is_deleted': fields.Boolean(), 'last_online_ts': fields.Float(attribute=lambda s: s.last_online_ts and s.last_online_ts.timestamp()), 'created': fields.Float(attribute=lambda x: x.created.timestamp()), 'updated': fields.Float(attribute=lambda x: x.updated.timestamp()), }) page_of_staffs = api.inherit('Page of Staffs', pagination, { 'items': fields.List(fields.Nested(staff_data)) })
from flask_restplus import fields from app.apis import api from app.apis.serializers import pagination, PaginationSchema from app.apis.serializers.project import project_data, ProjectDataSchema, MessageSchema, message from app.apis.serializers.staff import raw_staff, RawStaffSchema from app import ma app_user = api.model('App User', { 'uid': fields.String(), 'name': fields.String(), }) session_item = api.model( 'Session Item', { 'id': fields.Integer(description='session id'), 'project': fields.Nested(project_data), 'created': fields.Float(attribute=lambda s: s.created.timestamp()), 'closed': fields.Float(attribute=lambda s: s.closed and s.closed.timestamp()), 'handler': fields.Nested(raw_staff), 'start_msg_id': fields.Integer(description='start msg id'), 'msg_id': fields.Integer(description='last msg id'), 'msg': fields.Nested(message, allow_null=True, description='last msg'), 'last_session_msg':
from flask_restplus import fields from app.apis import api from app.apis.serializers.xfields import any_of new_msg = api.model( 'New Test App Channel Msg', { "channel": fields.String(required=True), "project_domain": fields.String(required=True), "project_type": fields.String(required=True), "project_biz_id": fields.String(required=True), "project_id": fields.Integer(required=True, min=1, example=123), "uid": fields.String(required=True), "staff_uid": fields.String(required=True), "type": fields.String(required=True), "content": any_of(['string', 'object']) })
from flask_restplus import fields from app.apis.serializers.xfields import Any from app.apis import api notified_event = api.model('notified event', { 'event': fields.String(required=True, example='msg', description='notify event name'), 'data': Any(required=True), }) notified_msg = api.model('notified msg', { 'kind': fields.String(required=True, enum=('chat', 'chat_notify'), example='chat', description='msg kind'), 'chat_id': fields.String(required=True, example='group.1', description='msg kind'), 'user': fields.String(required=True, example='cs:test:customer:u#001', description='xchat chat member uid'), 'id': fields.Integer(required=False, min=1, description='msg id'), 'msg': fields.String(required=True, description='msg content'), 'ts': fields.Integer(required=True, description='msg timestamp(unit: s)'), 'domain': fields.String(required=False, example='cs', description='msg domain'), }) user_status = api.model('user status', { 'user': fields.String(required=True), 'status': fields.String(required=True, enum=('online', 'offline')), }) notified_user_status = api.model('notified user status', { 'statuses': fields.List(fields.Nested(user_status), required=True), })