import { AxiosResponse } from 'axios';
|
import { http } from "./httpClient";
|
import { editAppointmentParams } from '../models/editAppointmentParams.model';
|
import { AppointmentDetail } from '../models/AppointmentDetail';
|
import { ConsultantLoginInfo } from '../models/ConsultantLoginInfo';
|
import { UserSetting } from '../models/account.model';
|
import { FastQueryParams } from '../models/quickFilter.model';
|
import { LoginRequest } from "../models/loginRequest.model";
|
import { OtpInfo } from "../models/otpInfo.model";
|
import { Consultant } from '../models/consultant.model';
|
import { RegisterInfo } from '../models/registerInfo';
|
import { LoginVerify } from '../models/loginVerify.model';
|
import { StrictQueryParams } from '../models/strictQueryParams';
|
import { AppointmentParams } from '../models/appointmentParams';
|
import { UserReviewsConsultantsParams } from '../models/UserReviewsConsultantsParams';
|
import { LoginSuccessToken } from '../models/loginSuccessToken.model';
|
import { AgentOfStrictQuery } from '../models/agentOfStrictQuery';
|
import _ from "lodash";
|
|
|
|
|
class PamService {
|
constructor() {}
|
|
/** 顧客登入-發送OTP **/
|
sendOtp(loginInfo: LoginRequest):Promise<AxiosResponse<OtpInfo>> {
|
return http.post('/otp/sendOtp', loginInfo).then( res => res.data );
|
}
|
|
/** 顧客登入-驗證OTP **/
|
loginVerify(loginVerify: LoginVerify):Promise<AxiosResponse<any>>{
|
return http.post('/otp/verify', loginVerify);
|
}
|
|
/** 顧客註冊 **/
|
register(registerInfo: RegisterInfo):Promise<AxiosResponse<any>>{
|
return http.post('/otp/register', registerInfo);
|
}
|
|
/** 推薦保險顧問 **/
|
recommend():Promise<AxiosResponse<Consultant[]>>{
|
return http.get('/consultant/recommend');
|
}
|
|
/** 快速篩選 **/
|
fastQuery(data: FastQueryParams):Promise<AxiosResponse<Consultant[]>>{
|
return http.post('/consultant/fastQuery', data)
|
}
|
|
/** 嚴選配對 **/
|
strictQuery(data:StrictQueryParams):Promise<AxiosResponse<AgentOfStrictQuery[]>>{
|
return http.post('/consultant/strictQuery', data)
|
}
|
|
/** 加入顧問 **/
|
addFavoriteConsultant(agentNoList: string[]):Promise<AxiosResponse<any>>{
|
return http.post('/consultant/favorite', {agentNoList})
|
}
|
|
/** 預約前詢問 **/
|
appointmentDemand(data: AppointmentParams):Promise<AxiosResponse<any>> {
|
return http.post('/appointment/customer/create', data)
|
}
|
|
/** 顧問詳細資訊 **/
|
getConsultantDetail(agentNo:string):Promise<AxiosResponse<any>>{
|
return http.get('/consultant/detail', {params:{agentNo:agentNo}})
|
}
|
|
/** 移除顧問 **/
|
deleteConsultant(agentId: string):Promise<AxiosResponse<any>>{
|
return http.delete('/consultant/favorite/'+agentId);
|
}
|
|
/** 取得驗證碼圖片 **/
|
getImgOfVerification():Promise<string>{
|
return http.get('/login/validate/get_img_code',{ responseType : 'arraybuffer' })
|
.then( response => {
|
const toBase64 = window.btoa(
|
_.reduce( new Uint8Array(response.data),(data,byte) =>
|
data + String.fromCharCode(byte),'')
|
);
|
const imgSrc = `data:image/jpeg;base64,${toBase64}`;
|
return imgSrc;
|
});
|
}
|
|
/** 驗證碼-驗證 **/
|
getVerificationStatus(imgCode:string):Promise<AxiosResponse<boolean>>{
|
return http.get('/login/validate/verify_img_code/'+imgCode);
|
}
|
|
/** 顧問登入 **/
|
logInToConsultant(consultantDto:ConsultantLoginInfo):Promise<AxiosResponse<LoginSuccessToken>>{
|
return http.post('/ehttp/authenticate',consultantDto);
|
}
|
|
/** 取得預約單細節 **/
|
getAppointmentDetail(apointmentId: number):Promise<AxiosResponse<AppointmentDetail>> {
|
return http.get('/appointment/getDetail/'+apointmentId)
|
}
|
|
/** 取得使用者帳號資訊 **/
|
getUserAccountSetting():Promise<AxiosResponse<UserSetting>>{
|
return http.get<UserSetting>('/customer/info');
|
}
|
|
/** 更新使用者帳號資訊 **/
|
updateAccountSetting(params: any):Promise<AxiosResponse<any>> {
|
return http.put('/customer/info', params);
|
}
|
|
//客戶進行滿意度評分
|
userReviewsConsultants(data: UserReviewsConsultantsParams):Promise<AxiosResponse<any>> {
|
return http.post('/satisfaction/create', data);
|
}
|
|
// 取消預約
|
cancelAppointment(appointment: number):Promise<AxiosResponse<any>>{
|
return http.delete('/appointment/'+appointment);
|
}
|
|
// 編輯預約
|
editAppointment(editAppointmentParams:editAppointmentParams):Promise<AxiosResponse<any>>{
|
return http.put('/appointment', editAppointmentParams);
|
}
|
}
|
|
export default new PamService();
|