/** Angular Routes */ import { Injectable } from '@angular/core' ; import { HttpClient , HttpParams } from '@angular/common/http' ; /** rxjs Imports */ import { Observable } from 'rxjs' ; import { map } from 'rxjs/operators' ; /** Custom Models */ import { User } from './user.model' ; /**
 * Self service users service.
 *
 * TODO: Complete functionality once API is available.
 */ @ Injectable ( { providedIn : 'root' } ) export class UserService { param { HttpClient } http constructor ( private http ) { } /**
     * Gets all the self service users.
     *
     * TODO: To be replaced once API is available.
     */ getUsers ( ) { const httpParams = new HttpParams ( ) . set ( 'fields' , 'id,firstname,lastname,email,officeName,staff' ) ; return this . http . get ( '/users' , { params : httpParams } ) . pipe ( map ( ( users ) => { users . forEach ( ( user ) => { user . name = `${ user . firstname } ${ user . lastname }` ; user . staff = user . staff ? `${ user . staff . firstname } ${ user . staff . lastname }` : '' ; delete user . firstname ; delete user . lastname ; } ) ; return users as User [ ] ; } ) ) ; } /**
     * Gets a self service user.
     *
     * TODO: Mock data to be replaced once API is available.
     */ getUser ( ) { return this . http . disableApiPrefix ( ) . get ( '/assets/mock/user.mock.json' ) ; } param userId param password returns { Observable < any > } changePassword ( userId , passwordObj ) { return this . http . put ( `/self/user/${ userId }` , passwordObj ) ; } }