import BridgeFunction from './bridgeFunction'; import { MiniAppError, MiniAppErrorType } from '../miniAppError'; import { getUserProfile } from '../../factory/api'; class GetUserProfile extends BridgeFunction { name = 'getUserProfile'; protected async executeFunction() { const res: any = await getUserProfile(); if (res?.data?.unsigned?.resultInfo?.code === 'SUCCESS') { const data = res?.data?.unsigned?.data; const name = [data?.lastName, data?.firstName].join(' '); return this.cbHandler?.success({ fullname: name.length === 1 ? null : name, nickName: data?.displayName, avatarUrl: data?.photoUrl, email: data?.email, phoneNumber: data?.mobile, }); } else { throw new MiniAppError(MiniAppErrorType.serverError); } } } export default GetUserProfile;