from project.api import api
from flask_restplus import fields

sentiment_json = api.model(
    "Sentiment json",
    {"text": fields.String(required=True, description="Text to be analyzed")})

sentiments_json = api.model(
    "Sentiments json",
    {
        "texts":
        fields.List(fields.Nested(sentiment_json), description="List of text")
    },
)
示例#2
0
    description='Whether an event should be scheduled on this day')
weekend = fields.Boolean(
    default=False,
    description='Whether an event should be scheduled on this day')
days_input_output = {
                     'sunday': weekend,
                     'monday': weekday,
                     'tuesday': weekday,
                     'wednesday': weekday,
                     'thursday': weekday,
                     'friday': weekday,
                     'saturday': weekend}
availability_input_output = api.model(
    'Availability', {
        'start': Time(
            description='Your earliest availability for the event',),
        'end': Time(
            description='Your latest availability for the event',),
        'days': days_input_output})
event_input_output = api.model(
    'Event', {
        'name': fields.String(
            description='The name of the event', required=True,
            example='My event', min_length=1, max_length=32),
        'location': fields.String(
            default=None,
            description='The location where the event will take place',
            example='My office', max_length=256),
        'description': fields.String(
            default=None, description='A description for the event',
            example='This is an awesome description.', max_length=1024),
示例#3
0
from project.error_handlers import *
from project.models.user import User, add_user, update_user, Role

users_blueprint = Blueprint('users', __name__)

#-------------------------------------------------------------------------------
# Serializers
#-------------------------------------------------------------------------------

user_model = api.model(
    'User', {
        'public_id':
        fields.String(description="unique identifier of the user"),
        'name':
        fields.String(required=True, description="The name of the user"),
        'email':
        fields.String(required=True, description="The unique email"),
        'img_url':
        fields.String(
            description="The image url of the user's Google account"),
        'role':
        fields.String(description='The object type', enum=Role._member_names_),
    })

#-------------------------------------------------------------------------------
# Endpoints
#-------------------------------------------------------------------------------


@api.route('/users')
class UserList(Resource):
    @api.marshal_with(user_model)  #output validation
示例#4
0

timezones_model = api.model(
    'Timezone', {
        'name':
        fields.String(description='The name of the timezone',
                      example='America/Toronto'),
        'offset hours':
        OffsetHours(description='The UTC offset hours only.',
                    attribute='offset',
                    required=True,
                    example=-5),
        'offset minutes':
        OffsetMinutes(description='The UTC offset minutes '
                      'only.',
                      attribute='offset',
                      required=True,
                      example=0),
        'dst offset hours':
        OffsetHours(description='The daylight savings time '
                    'UTC offset hours only.',
                    attribute='dst_offset',
                    example=-4),
        'dst offset minutes':
        OffsetMinutes(description='The UTC offset minutes'
                      ' only.',
                      attribute='dst_offset',
                      example=0)
    })

示例#5
0
from google.oauth2 import id_token
from project import db
from project.api import api
from project.models.blacklist_token import BlacklistToken
from project.models.user import User, add_user
from project.models.creds import add_cred
from project.decorators import token_required
from project.services.google_calendar import fetch_free_busy
import google_auth_oauthlib
import flask
from project.services.google_auth import exchange_auth_code

login_blueprint = Blueprint('login', __name__)

login_input = api.model(
    'login', {
        'code': fields.String(required=True),
    })


@api.route('/login')
class Login(Resource):
    @api.expect(login_input)  #input validation
    def post(self):
        # (Receive Authorization codde)
        data = api.payload
        credentials = exchange_auth_code(data['code'])
        token = credentials['id_token']
        access_token = credentials['access_token']
        refresh_token = credentials[
            'refresh_token'] if 'refresh_token' in credentials else None
        try: