import { inject, Injectable } from '@angular/core';

import { Base } from '../base/base';

@Injectable()
export class UserService extends Base
{
  public addUser(params: any)
  {
    return this.api.post('v1/users/addUser', params);
  }

  public editUser(params: any)
  {
    return this.api.post('v1/users/editUser', params);
  }

  public deleteUser(userId: number)
  {
    const params: any = { userId: userId };
    return this.api.post('v1/users/deleteUser', params);
  }

  public validateOtp(userId: number, authMethod: number, otpCode: string)
  {
    const params: any = { userId: userId, authMethod: authMethod, otpCode: otpCode };
    return this.api.post('v1/users/validateOtp', params);
  }

  public unlockUser(userId: number, loginId: string)
  {
    const params: any = { userId: userId, loginId: loginId };
    return this.api.post('v1/users/unlockUser', params);
  }

  public getUser(userId: number)
  {
    const params: any = { userId: userId };
    return this.api.post('v1/users/getUser', params);
  }

  public getUsers(params: any)
  {
    return this.api.post('v1/users/getUsers', params);
  }

  public getCurrentUser()
  {
    const params: any = { noParameter: 0 };
    return this.api.post('v1/users/getCurrentUser', params);
  }

  public getMyProfile()
  {
    const params: any = { noParameter: 0 };
    return this.api.post('v1/users/getMyProfile', params);
  }

  public getMyPayslip(params: any)
  {
    return this.api.post('v1/users/getMyPayslip', params);
  }

  public sendToRabbitMQ(params: any)
  {
    return this.api.post('RabbitQueueProducer/sendMessage', params);
  }

  public getDashboardData()
  {
    const params: any = { noParameter: 0 };
    return this.api.post('v1/users/getDashboardData', params);
  }

  public changeStatus(params: any)
  {
    return this.api.post('v1/users/updatestatus', params);
  }

  public getAttributes(userId: number, clientType: number)
  {
    const params: any = { userId: userId, clientType: clientType };
    return this.api.post('v1/users/getAttributes', params);
  }

  public saveAttributes(params: any)
  {
    return this.api.post('v1/users/saveAttributes', params);
  }

  public deleteAttributes(userId: number, clientType: number)
  {
    const params: any = { userId: userId, clientType: clientType };
    return this.api.post('v1/users/deleteAttributes', params);
  }

  public changePassword(userId: number, oldPassword: string, newPassword: string, confirmPassword: string)
  {
    const params: any = { userId: userId, oldPassword: oldPassword, password: newPassword, confirmPassword: confirmPassword };
    return this.api.post('v1/users/changePassword', params);
  }

  public updateMyPassword(oldPassword: string, newPassword: string, confirmPassword: string)
  {
    const params: any = { oldPassword: oldPassword, password: newPassword, confirmPassword: confirmPassword };
    return this.api.post('v1/users/updateMyPassword', params);
  }

  public resetPassword(userId: number, newPassword: string, confirmPassword: string)
  {
    const params: any = { userId: userId, password: newPassword, confirmPassword: confirmPassword };
    return this.api.post('v1/users/resetPassword', params);
  }

  public findAccount(accountId: string)
  {
    const params: any = { accountId: accountId };
    return this.api.post('v1/users/findAccount', params);
  }

  public sendPassword(params: any)
  {
    return this.api.post('v1/users/sendPassword', params);
  }

  public updateMyTheme(menuLayout: string, themeName: string, schemeName: string)
  {
    const params: any = { menuLayout: menuLayout, themeName: themeName, schemeName: schemeName };
    return this.api.post('v1/users/updateMyTheme', params);
  }

  public sendQrCodeViaEmail(formdata: FormData)
  {
    return this.api.uplaodFormData('v1/users/sendQrCodeViaEmail', formdata);
  }

  public uploadProfileImage(formdata: FormData)
  {
    return this.api.uplaodFormData('v1/users/uploadProfileImage', formdata);
  }

  public updateMyInfo(params: any)
  {
    return this.api.post('v1/users/updateMyInfo', params);
  }

  public uploadDocument(formdata: FormData)
  {
    return this.api.uplaodFormData('v1/users/uploadDocument', formdata);
  }

  public getDocument(fileName: string)
  {
    const params: any = { fileName: fileName };
    return this.api.post('v1/users/getDocument', params);
  }

  public printPO(poId: number)
  {
    const params: any = { poId: poId };
    return this.api.post('v1/users/printPO', params);
  }

  public printWO(woId: number)
  {
    const params: any = { woId: woId };
    return this.api.post('v1/users/printWO', params);
  }

  public printFaReport(reportId: number, txnId: number, cashPurchase: boolean)
  {
    const params: any = { reportId: reportId, tranId: txnId, cashPurchase: cashPurchase };
    return this.api.post('v1/users/printFaReport', params);
  }

  public printInvoice(invoiceId: number)
  {
    const params: any = { invoiceId: invoiceId };
    return this.api.post('v1/users/printInvoice', params);
  }

  public printVoucher(tranId: number)
  {
    const params: any = { tranId: tranId };
    return this.api.post('v1/users/printVoucher', params);
  }

  public loadMenu(userId: number)
  {
    const params: any = { userId: userId };
    return this.api.post('v1/users/loadMenu', params);
  }

  public getUsersForForceLogout()
  {
    const params: any = { noParameter: 0 };
    return this.api.post('v1/users/getUsersForForceLogout', params)
  }

  public forceLogoutNow(params: any)
  {
    return this.api.post('v1/users/forceLogoutNow', params)
  }

  public getUsersBasic(applyFilter: boolean, teamSpaceId: number = 0, projectId: number = 0)
  {
    const params: any = { applyFilter: applyFilter, teamSpaceId: teamSpaceId, projectId: projectId };
    return this.api.post('v1/users/getUsersBasic', params)
  }

  public getAttendanceUsers(userId: number = 0)
  {
    const params: any = { userId: userId };
    return this.api.post('v1/users/getAttendanceUsers', params)
  }

  public getUsersByTeamSpace(teamSpaceId: number, projectId: number = 0, userId: number = 0)
  {
    const params: any = { teamSpaceId: teamSpaceId, projectId: projectId, userId: userId };
    return this.api.post('v1/users/getUsersByTeamSpace', params)
  }

  public getAccessLog(params: any)
  {
    return this.api.post('v1/users/getAccessLog', params);
  }

  public getTeamSpaces()
  {
    const params: any = { status: 8 };
    return this.api.post('v1/teamspaces/getTeamSpaces', params);
  }

  public getAuthorizeLimit(userId: number)
  {
    const params: any = { userId: userId };
    return this.api.post('v1/users/getAuthorizeLimit', params);
  }

  public saveAuthorizeLimit(params: any)
  {
    return this.api.post('v1/users/saveAuthorizeLimit', params);
  }

  public findKeywordsFromAudio(formdata: FormData)
  {
    return this.api.uplaodFormData('aiApiMiddleware/findKeywordsFromAudio', formdata);
  }

}
