# Path: apis/auth/api/oauth_token_code.py
# class OauthTokenCode(Resource):
# 
#     async def post(self, request):
#         print(request.json)
#         print(request.headers)
# 
#         return {'account_id': 'something', 'access_token': 'something', 'token_type': 'jwt'}, 200, None
# 
# Path: apis/auth/api/accounts_self.py
# class AccountsSelf(Resource):
# 
#     async def get(self, request):
#         if not current_account.id:
#             raise NotFound('account_not_found')
#         account = Account.objects(id=current_account.id).first()
#         if not account:
#             raise NotFound('account_not_found')
#         return account, 200
# 
# Path: apis/auth/api/oauth_token.py
# class OauthToken(Resource):
# 
#     async def post(self, request):
#         is_validate, token = create_token(request)
#         if not is_validate:
#             raise Unauthorized('unauthorized', 'Invalid token', '用户未注册')
#         return token, 201
# 
# Path: apis/auth/api/self_password_reset.py
# class SelfPasswordReset(Resource):
# 
#     async def post(self, request):
#         print(request.json)
#         print(request.headers)
# 
#         return {}, 200, None
# 
# Path: apis/auth/api/self_password.py
# class SelfPassword(Resource):
# 
#     async def post(self, request):
#         print(request.json)
#         return {'hahahha': 1234}, 201
#         return {}, 201, None
# 
#     async def put(self, request):
#         print(request.json)
#         print(request.headers)
#         return {'hahahha': 1234}
# 
#         return {}, 200, None
# 
# Path: apis/auth/api/oauth_token_refresh.py
# class OauthTokenRefresh(Resource):
# 
#     async def post(self, request):
#         print(request.json)
#         print(request.headers)
# 
#         return {'account_id': 'something', 'access_token': 'something', 'refresh_token': 'something', 'token_type': 'Bearer', 'expires_in': 9573, 'scopes': 'something'}, 200, None
# 
# Path: apis/auth/api/accounts_wxapp.py
# class AccountsWxapp(Resource):
# 
#     async def post(self, request):
#         encrypted_data = request.json.get('username')
#         iv = request.json.get('password')
#         code = request.json.get('code')
#         user_info = get_wxapp_userinfo(encrypted_data, iv, code)
#         openid = user_info.get('openId')
#         account = Account.get_by_wxapp(openid=openid)
#         if account:
#             raise BadRequest('wxapp_already_registered')
#         params = {
#             'id': generation_objectid(),
#             'nickname': user_info['nickName'],
#             'avatar': user_info['avatarUrl'],
#             'authentications': {'wxapp': openid},
#         }
#         account = Account(**params)
#         account.save()
#         return account, 201


from .api.oauth_token_code import OauthTokenCode
from .api.accounts_self import AccountsSelf
from .api.oauth_token import OauthToken
from .api.self_password_reset import SelfPasswordReset
from .api.self_password import SelfPassword
from .api.oauth_token_refresh import OauthTokenRefresh
from .api.accounts_wxapp import AccountsWxapp
# -*- coding: utf-8 -*-

###
### DO NOT CHANGE THIS FILE
### 
### The code is auto generated, your change will be overwritten by 
### code generating.
###
from __future__ import absolute_import



routes = [
    dict(resource=OauthTokenCode.as_view(), urls=['/oauth/token/code'], endpoint='oauth_token_code'),
    dict(resource=AccountsSelf.as_view(), urls=['/accounts/self'], endpoint='accounts_self'),
    dict(resource=OauthToken.as_view(), urls=['/oauth/token'], endpoint='oauth_token'),
    dict(resource=SelfPasswordReset.as_view(), urls=['/self/password/reset'], endpoint='self_password_reset'),
    dict(resource=SelfPassword.as_view(), urls=['/self/password'], endpoint='self_password'),
    dict(resource=OauthTokenRefresh.as_view(), urls=['/oauth/token/refresh'], endpoint='oauth_token_refresh'),
    dict(resource=AccountsWxapp.as_view(), urls=['/accounts/wxapp'], endpoint='accounts_wxapp'),

# Path: apis/auth/api/oauth_token_code.py
# class OauthTokenCode(Resource):
# 
#     async def post(self, request):
#         print(request.json)
#         print(request.headers)
# 
#         return {'account_id': 'something', 'access_token': 'something', 'token_type': 'jwt'}, 200, None
# 
# Path: apis/auth/api/accounts_self.py
# class AccountsSelf(Resource):
# 
#     async def get(self, request):
#         if not current_account.id:
#             raise NotFound('account_not_found')
#         account = Account.objects(id=current_account.id).first()
#         if not account:
#             raise NotFound('account_not_found')
#         return account, 200
# 
# Path: apis/auth/api/oauth_token.py
# class OauthToken(Resource):
# 
#     async def post(self, request):
#         is_validate, token = create_token(request)
#         if not is_validate:
#             raise Unauthorized('unauthorized', 'Invalid token', '用户未注册')
#         return token, 201
# 
# Path: apis/auth/api/self_password_reset.py
# class SelfPasswordReset(Resource):
# 
#     async def post(self, request):
#         print(request.json)
#         print(request.headers)
# 
#         return {}, 200, None
# 
# Path: apis/auth/api/self_password.py
# class SelfPassword(Resource):
# 
#     async def post(self, request):
#         print(request.json)
#         return {'hahahha': 1234}, 201
#         return {}, 201, None
# 
#     async def put(self, request):
#         print(request.json)
#         print(request.headers)
#         return {'hahahha': 1234}
# 
#         return {}, 200, None
# 
# Path: apis/auth/api/oauth_token_refresh.py
# class OauthTokenRefresh(Resource):
# 
#     async def post(self, request):
#         print(request.json)
#         print(request.headers)
# 
#         return {'account_id': 'something', 'access_token': 'something', 'refresh_token': 'something', 'token_type': 'Bearer', 'expires_in': 9573, 'scopes': 'something'}, 200, None
# 
# Path: apis/auth/api/accounts_wxapp.py
# class AccountsWxapp(Resource):
# 
#     async def post(self, request):
#         encrypted_data = request.json.get('username')
#         iv = request.json.get('password')
#         code = request.json.get('code')
#         user_info = get_wxapp_userinfo(encrypted_data, iv, code)
#         openid = user_info.get('openId')
#         account = Account.get_by_wxapp(openid=openid)
#         if account:
#             raise BadRequest('wxapp_already_registered')
#         params = {
#             'id': generation_objectid(),
#             'nickname': user_info['nickName'],
#             'avatar': user_info['avatarUrl'],
#             'authentications': {'wxapp': openid},
#         }
#         account = Account(**params)
#         account.save()
#         return account, 201


# Path: apis/auth/routes.py
from .api.oauth_token_code import OauthTokenCode
from .api.accounts_self import AccountsSelf
from .api.oauth_token import OauthToken
from .api.self_password_reset import SelfPasswordReset
from .api.self_password import SelfPassword
from .api.oauth_token_refresh import OauthTokenRefresh
from .api.accounts_wxapp import AccountsWxapp

# -*- coding: utf-8 -*-

###
### DO NOT CHANGE THIS FILE
### 
### The code is auto generated, your change will be overwritten by 
### code generating.
###
from __future__ import absolute_import



routes = [
    dict(resource=OauthTokenCode.as_view(), urls=['/oauth/token/code'], endpoint='oauth_token_code'),
    dict(resource=AccountsSelf.as_view(), urls=['/accounts/self'], endpoint='accounts_self'),
    dict(resource=OauthToken.as_view(), urls=['/oauth/token'], endpoint='oauth_token'),
    dict(resource=SelfPasswordReset.as_view(), urls=['/self/password/reset'], endpoint='self_password_reset'),
    dict(resource=SelfPassword.as_view(), urls=['/self/password'], endpoint='self_password'),
    dict(resource=OauthTokenRefresh.as_view(), urls=['/oauth/token/refresh'], endpoint='oauth_token_refresh'),
    dict(resource=AccountsWxapp.as_view(), urls=['/accounts/wxapp'], endpoint='accounts_wxapp'),

]