import { ServerRoute } from '@hapi/hapi'
import { UserHandler } from '../handlers/user.handler'
import { options } from "../validators/global.validator.schema"
import { Common } from "../../utils/common"
import {
    signUpRequest,
    signUpResponse,
    verifyEmailRequest,
    resendCodeRequest,
    loginWithEmailPassworRequest,
    loginWithUsernamePassworRequest,
    loginWithMobilePassworRequest,
    loginWithMobileRequest,
    loginResponse,
    forgotPasswordRequest,
    forgotPasswordResponse,
    resetPasswordRequest,
    changePasswordRequest,
    updatePasswordRequest,
    userListRequest,
    logoutRequest,
    userExportRequest,
    TokenFromRefreshRequest,
    TokenFromRefreshResponse,
    uniqueIdentifierSchema,
    socialLoginRequest,
    userDeviceRegistrationRequest,
    changeEmailRequest,
    changeEmailResponse,
    userUpdateProfileRequest,
    updateProfileStatusRequest,
    createUserRequest,
    userListAllRequest,
    mobileLoginResponse,
    verifyMobileRequest,
    applyReferralRequest,
    changeMobileRequest,
    changeMobileResponse,
    userReferralRequest,
    verifyDeleteAccountRequest,
    updateReferralCodeRequest,
    userFlowQuery,
    userFollowListRequest,
    userResponse,
    userProfileResponse,
    userListResponse,
    userPublicListResponse,
    userListAllResponse
} from "../validators/user.validator"
const userHandler = new UserHandler();
import { I18N } from '../../utils/i18n';
import { error400, error401, error403, error404, error500, confirmationOnly } from "../validators/global.validator.schema"

const routes: ServerRoute[] = [
    {
        method: 'POST',
        path: '/user/signup',
        handler: userHandler.signup,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 1 } },
            description: I18N.t('SIGN_UP_WITH_EMAIL_AND_USERNAME_DESCRIPTION'),
            notes: I18N.t('SIGN_UP_WITH_EMAIL_AND_USERNAME_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: signUpRequest,
            },
            response: {
                status: {
                    200: signUpResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/create',
        handler: userHandler.create,
        options: {
            tags: ['api', 'User'],
            plugins: { 'hapi-swagger': { order: 1 } },
            description: I18N.t('CREATE_WITH_EMAIL_DESCRIPTION'),
            notes: I18N.t('CREATE_WITH_EMAIL_NOTE'),
            auth: { strategies: ['jwt'], scope: ['admin', 'manageUsers'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                payload: createUserRequest,
            },
            response: {
                status: {
                    200: userResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'PATCH',
        path: '/user/{id}/set-password',
        handler: userHandler.setPassword,
        options: {
            tags: ['api', 'User'],
            plugins: { 'hapi-swagger': { order: 1 } },
            description: I18N.t('CREATE_WITH_EMAIL_DESCRIPTION'),
            notes: I18N.t('CREATE_WITH_EMAIL_NOTE'),
            auth: { strategies: ['jwt'], scope: ['admin', 'manageUsers'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                payload: changePasswordRequest,
                params: uniqueIdentifierSchema
            },
            response: {
                status: {
                    //200: loginResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'PATCH',
        path: '/user/{id}/update',
        handler: userHandler.update,
        options: {
            tags: ['api', 'User'],
            plugins: { 'hapi-swagger': { order: 1 } },
            description: I18N.t('CREATE_WITH_EMAIL_DESCRIPTION'),
            notes: I18N.t('CREATE_WITH_EMAIL_NOTE'),
            auth: { strategies: ['jwt'], scope: ['admin', 'manageUsers'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                params: uniqueIdentifierSchema,
                payload: createUserRequest,
            },
            response: {
                status: {
                    200: userResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/verifyEmail',
        handler: userHandler.verifyEmail,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 2 } },
            description: I18N.t('VERIFY_EMAIL_DESCRIPTION'),
            notes: I18N.t('VERIFY_EMAIL_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: verifyEmailRequest,
            },
            response: {
                status: {
                    200: loginResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'POST',
        path: '/user/verifyMobile',
        handler: userHandler.verifyMobile,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 2 } },
            description: I18N.t('VERIFY_EMAIL_DESCRIPTION'),
            notes: I18N.t('VERIFY_EMAIL_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: verifyMobileRequest,
            },
            response: {
                status: {
                    200: loginResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'POST',
        path: '/user/resendCode',
        handler: userHandler.resendCode,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 3 } },
            description: I18N.t('RESEND_VERIFICATION_CODE_DESCRIPTION'),
            notes: I18N.t('RESEND_VERIFICATION_CODE_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: resendCodeRequest,
            },
            response: {
                status: {
                    200: signUpResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'POST',
        path: '/user/login/email',
        handler: userHandler.login,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 4 } },
            description: I18N.t('LOGIN_WITH_EMAIL_AND_PASSWORD_DESCRIPTION'),
            notes: I18N.t('LOGIN_WITH_EMAIL_AND_PASSWORD_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: loginWithEmailPassworRequest,
            },
            response: {
                status: {
                    200: loginResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/login/username',
        handler: userHandler.login,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 5 } },
            description: I18N.t('LOGIN_WITH_USERNAME_AND_PASSWORD_DESCRIPTION'),
            notes: I18N.t('LOGIN_WITH_USERNAME_AND_PASSWORD_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: loginWithUsernamePassworRequest,
            },
            response: {
                status: {
                    200: loginResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/login/mobile-password',
        handler: userHandler.login,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 6 } },
            description: I18N.t('LOGIN_WITH_MOBILE_AND_PASSWORD_DESCRIPTION'),
            notes: I18N.t('LOGIN_WITH_MOBILE_AND_PASSWORD_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: loginWithMobilePassworRequest,
            },
            response: {
                status: {
                    200: loginResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/login/mobile',
        handler: userHandler.mobileLogin,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 7 } },
            description: I18N.t('MOBILE_LOGIN_DESCRIPTION'),
            notes: I18N.t('MOBILE_LOGIN_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: loginWithMobileRequest,
            },
            response: {
                status: {
                    200: mobileLoginResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'POST',
        path: '/user/forgot-password',
        handler: userHandler.forgotPassword,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 8 } },
            description: I18N.t('FORGOT_PASSWORD_DESCRIPTION'),
            notes: I18N.t('FORGOT_PASSWORD_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: forgotPasswordRequest,
            },
            response: {
                status: {
                    200: forgotPasswordResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/reset-password',
        handler: userHandler.resetPassword,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 9 } },
            description: I18N.t('RESET_PASSWORD_DESCRIPTION'),
            notes: I18N.t('RESET_PASSWORD_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: resetPasswordRequest,
            },
            response: {
                status: {
                    200: loginResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/change-password',
        handler: userHandler.changePassword,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 10 } },
            description: I18N.t('CHANGE_PASSWORD_DESCRIPTION'),
            notes: I18N.t('CHANGE_PASSWORD_NOTE'),
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders('authorized'),
                options: options,
                failAction: Common.failover,
                payload: changePasswordRequest,
            },
            response: {
                status: {
                    200: confirmationOnly,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/update-password',
        handler: userHandler.updatePassword,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 10 } },
            description: 'Update Password',
            notes: 'Update Password',
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders('authorized'),
                options: options,
                failAction: Common.failover,
                payload: updatePasswordRequest,
            },
            response: {
                status: {
                    200: confirmationOnly,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/refreshToken',
        handler: userHandler.tokenWithRefreshToken,
        options: {
            tags: ['api', 'User Auth'],
            description: I18N.t('REFRESH_TOKEN_DESCRIPTION'),
            notes: I18N.t('REFRESH_TOKEN_NOTE'),
            plugins: { 'hapi-swagger': { order: 11 } },
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: TokenFromRefreshRequest
            },
            response: {
                status: {
                    200: TokenFromRefreshResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/logout',
        handler: userHandler.logout,
        options: {
            tags: ['api', 'User Auth'],
            description: I18N.t('LOGOUT_USER_DESCRIPTION'),
            notes: I18N.t('LOGOUT_USER_NOTE'),
            plugins: { 'hapi-swagger': { order: 12 } },
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                payload: logoutRequest
            },
            response: {
                status: {
                    200: confirmationOnly,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'GET',
        path: '/user/public/list',
        handler: userHandler.publicList,
        options: {
            tags: ['api', 'User'],
            description: I18N.t('LIST_USER_DESCRIPTION'),
            notes: I18N.t('LIST_USER_NOTE'),
            plugins: { 'hapi-swagger': { order: 13 } },
            auth: { strategies: ['jwt'], scope: ['admin', 'manageUsers', 'user'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                query: userListRequest
            },
            response: {
                status: {
                    200: userPublicListResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'GET',
        path: '/user/list',
        handler: userHandler.list,
        options: {
            tags: ['api', 'User'],
            description: I18N.t('LIST_USER_DESCRIPTION'),
            notes: I18N.t('LIST_USER_NOTE'),
            plugins: { 'hapi-swagger': { order: 13 } },
            auth: { strategies: ['jwt'], scope: ['admin', 'manageUsers', 'user'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                query: userListRequest
            },
            response: {
                status: {
                    200: userListResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'GET',
        path: '/user/referral-list',
        handler: userHandler.referralList,
        options: {
            tags: ['api', 'User'],
            description: I18N.t('LIST_USER_DESCRIPTION'),
            notes: I18N.t('LIST_USER_NOTE'),
            plugins: { 'hapi-swagger': { order: 13 } },
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                query: userReferralRequest
            },
            response: {
                status: {
                    //200: userListResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'GET',
        path: '/user/{id}/referral-list',
        handler: userHandler.referralListOfUser,
        options: {
            tags: ['api', 'User'],
            description: I18N.t('LIST_USER_DESCRIPTION'),
            notes: I18N.t('LIST_USER_NOTE'),
            plugins: { 'hapi-swagger': { order: 13 } },
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                params: uniqueIdentifierSchema,
                query: userReferralRequest
            },
            response: {
                status: {
                    //200: userListResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'GET',
        path: '/user/listAll',
        handler: userHandler.listAll,
        options: {
            tags: ['api', 'User'],
            description: I18N.t('LIST_ALL_USER_DESCRIPTION'),
            notes: I18N.t('LIST_ALL_USER_NOTE'),
            plugins: { 'hapi-swagger': { order: 14 } },
            auth: { strategies: ['jwt'], scope: ['admin', 'manageUsers', 'manageLiveStreams'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                query: userListAllRequest
            },
            response: {
                status: {
                    200: userListAllResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'GET',
        path: '/user/export',
        handler: userHandler.export,
        options: {
            tags: ['api', 'User'],
            description: I18N.t('EXPORT_USER_DESCRIPTION'),
            notes: I18N.t('EXPORT_USER_NOTE'),
            plugins: { 'hapi-swagger': { order: 15 } },
            auth: { strategies: ['jwt'], scope: ['admin', 'manageUsers'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                query: userExportRequest
            },
            response: {
                status: {
                    //200: undefined,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'GET',
        path: '/user/profile',
        handler: userHandler.profile,
        options: {
            tags: ['api', 'User'],
            description: I18N.t('GET_USER_PROFILE_DESCRIPTION'),
            notes: I18N.t('GET_USER_PROFILE_NOTE'),
            plugins: { 'hapi-swagger': { order: 16 } },
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                query: uniqueIdentifierSchema
            },
            response: {
                status: {
                    200: userProfileResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'GET',
        path: '/user/{id}/profile',
        handler: userHandler.userProfile,
        options: {
            tags: ['api', 'User'],
            description: I18N.t('GET_USER_PROFILE_DESCRIPTION'),
            notes: I18N.t('GET_USER_PROFILE_NOTE'),
            plugins: { 'hapi-swagger': { order: 16 } },
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                params: uniqueIdentifierSchema
            },
            response: {
                status: {
                    200: userProfileResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/{id}/follow',
        handler: userHandler.toggleFollow,
        options: {
            tags: ['api', 'User'],
            description: I18N.t('TOGGLE_USER_FOLLOW_DESCRIPTION'),
            notes: I18N.t('TOGGLE_USER_FOLLOW_NOTE'),
            plugins: { 'hapi-swagger': { order: 16 } },
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                params: uniqueIdentifierSchema
            },
            response: {
                status: {
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'GET',
        path: '/user/{id}/followers',
        handler: userHandler.followersList,
        options: {
            tags: ['api', 'User'],
            description: I18N.t('LIST_USER_FOLLOWERS_DESCRIPTION'),
            notes: I18N.t('LIST_USER_FOLLOWERS_NOTE'),
            plugins: { 'hapi-swagger': { order: 16 } },
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                params: uniqueIdentifierSchema,
                query: userFollowListRequest
            },
            response: {
                status: {
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'GET',
        path: '/user/{id}/following',
        handler: userHandler.followingList,
        options: {
            tags: ['api', 'User'],
            description: I18N.t('LIST_USER_FOLLOWING_DESCRIPTION'),
            notes: I18N.t('LIST_USER_FOLLOWING_NOTE'),
            plugins: { 'hapi-swagger': { order: 16 } },
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                params: uniqueIdentifierSchema,
                query: userFollowListRequest
            },
            response: {
                status: {
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/social-login',
        handler: userHandler.socialLogin,
        options: {
            tags: ['api', 'User Auth'],
            description: I18N.t('SOCIAL_LOGIN_DESCRIPTION'),
            notes: I18N.t('SOCIAL_LOGIN_NOTE'),
            plugins: { 'hapi-swagger': { order: 17 } },
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: socialLoginRequest
            },
            response: {
                status: {
                    200: loginResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
    {
        method: 'POST',
        path: '/user/register/device',
        handler: userHandler.registerUserDevice,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 18 } },
            description: I18N.t('USER_DEVICE_REGISTRATION_DESCRIPTION'),
            notes: I18N.t('USER_DEVICE_REGISTRATION_NOTE'),
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                payload: userDeviceRegistrationRequest,
            },
            response: {
                status: {
                    200: confirmationOnly,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'POST',
        path: '/user/changeEmail',
        handler: userHandler.changeEmail,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 19 } },
            description: I18N.t('VERIFY_EMAIL_DESCRIPTION'),
            notes: I18N.t('VERIFY_EMAIL_NOTE'),
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                payload: changeEmailRequest,
            },
            response: {
                status: {
                    200: changeEmailResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'POST',
        path: '/user/changeMobile',
        handler: userHandler.changeMobile,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 19 } },
            description: I18N.t('VERIFY_MOBILE_DESCRIPTION'),
            notes: I18N.t('VERIFY_MOBILE_NOTE'),
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                payload: changeMobileRequest,
            },
            response: {
                status: {
                    200: changeMobileResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'PATCH',
        path: '/user/updateProfile',
        handler: userHandler.updateProfile,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 20 } },
            description: I18N.t('UPDATE_USER_PROFILE_DESCRIPTION'),
            notes: I18N.t('UPDATE_USER_PROFILE_NOTE'),
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                payload: userUpdateProfileRequest,
            },
            response: {
                status: {
                    200: confirmationOnly,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'PATCH',
        path: '/user/status/{id}',
        handler: userHandler.updateStatus,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 21 } },
            description: I18N.t('UPDATE_USER_PROFILE_STATUS_DESCRIPTION'),
            notes: I18N.t('UPDATE_USER_PROFILE_STATUS_NOTE'),
            auth: { strategies: ['jwt'], scope: ['admin', 'manageUsers'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                params: uniqueIdentifierSchema,
                payload: updateProfileStatusRequest,
            },
            response: {
                status: {
                    200: confirmationOnly,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'POST',
        path: '/user/apply-referral',
        handler: userHandler.applyReferral,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 21 } },
            description: I18N.t('APPLY_REFERRAL_DESCRIPTION'),
            notes: I18N.t('APPLY_REFERRAL_NOTE'),
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                payload: applyReferralRequest,
            },
            response: {
                status: {
                    // 200: confirmationOnly,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'POST',
        path: '/user/security-declaration',
        handler: userHandler.securityDeclaration,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 21 } },
            description: I18N.t('APPLY_REFERRAL_DESCRIPTION'),
            notes: I18N.t('APPLY_REFERRAL_NOTE'),
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover
            },
            response: {
                status: {
                    // 200: confirmationOnly,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'DELETE',
        path: '/user/delete-account',
        handler: userHandler.deleteAccount,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 21 } },
            description: I18N.t('APPLY_REFERRAL_DESCRIPTION'),
            notes: I18N.t('APPLY_REFERRAL_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: loginWithMobileRequest,
            },
            response: {
                status: {
                    // 200: confirmationOnly,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'DELETE',
        path: '/user/account',
        handler: userHandler.deleteAuthorizUserAccount,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 21 } },
            description: I18N.t('DELETE_USER_ACCOUNT_DESCRIPTION'),
            notes: I18N.t('DELETE_USER_ACCOUNT_NOTE'),
            auth: { strategies: ['jwt'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover
            },
            response: {
                status: {
                    // 200: confirmationOnly,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'POST',
        path: '/user/verify-delete-account',
        handler: userHandler.verifyDeleteAccount,
        options: {
            tags: ['api', 'User Auth'],
            plugins: { 'hapi-swagger': { order: 2 } },
            description: I18N.t('VERIFY_EMAIL_DESCRIPTION'),
            notes: I18N.t('VERIFY_EMAIL_NOTE'),
            auth: false,
            validate: {
                headers: Common.routeHeaders(),
                options: options,
                failAction: Common.failover,
                payload: verifyDeleteAccountRequest,
            },
            response: {
                status: {
                    // 200: loginResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'POST',
        path: '/user/runFlow',
        handler: userHandler.runFlow,
        options: {
            tags: ['api', 'User'],
            plugins: { 'hapi-swagger': { order: 22 } },
            description: I18N.t('RUN_USER_FLOW_DESCRIPTION'),
            notes: I18N.t('RUN_USER_FLOW_NOTE'),
            auth: { strategies: ['jwt'], scope: ['admin', 'manageUsers'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                query: userFlowQuery
            }
        },
    },
    {
        method: 'PATCH',
        path: '/user/{id}/update-referral-code',
        handler: userHandler.updateReferralCode,
        options: {
            tags: ['api', 'User'],
            plugins: { 'hapi-swagger': { order: 2 } },
            description: I18N.t('UPDATE_REFERRAL_CODE_DESCRIPTION'),
            notes: I18N.t('UPDATE_REFERRAL_CODE_NOTE'),
            auth: { strategies: ['jwt'], scope: ['admin', 'manageUsers'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                params: uniqueIdentifierSchema,
                payload: updateReferralCodeRequest,
            },
            response: {
                status: {
                    // 200: loginResponse,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }

            }
        },
    },
    {
        method: 'DELETE',
        path: '/user/{id}',
        handler: userHandler.deleteUser,
        options: {
            tags: ['api', 'User'],
            plugins: { 'hapi-swagger': { order: 1 } },
            description: I18N.t('DELETE_USER_DESCRIPTION'),
            notes: I18N.t('DELETE_USER_NOTE'),
            auth: { strategies: ['jwt'], scope: ['admin', 'manageUsers'] },
            validate: {
                headers: Common.routeHeaders("authorized"),
                options: options,
                failAction: Common.failover,
                params: uniqueIdentifierSchema
            },
            response: {
                status: {
                    200: confirmationOnly,
                    400: error400,
                    401: error401,
                    403: error403,
                    404: error404,
                    500: error500
                }
            }
        },
    },
]
export default routes;
