import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { User } from '../shared/models/user.model' ; import { Observable } from 'rxjs/internal/Observable' ; @ Injectable ( ) export class UserService { constructor ( private http ) { } register ( user ) { return this . http . post < User > ( '/api/account/user/register' , user ) ; } login ( credentials ) { return this . http . post < any > ( '/api/account/user/login' , credentials ) ; } getUsers ( ) { return this . http . get < User [ ] > ( '/api/account/users' ) ; } countUsers ( ) { return this . http . get < number > ( '/api/account/users/count' ) ; } addUser ( user ) { return this . http . post < User > ( '/api/account/user' , user ) ; } getUser ( user ) { return this . http . get < User > ( `/api/account/user/${ user . _id }` ) ; } editUser ( user ) { return this . http . put ( `/api/account/user/${ user . _id }` , user , { responseType : 'text' } ) ; } deleteUser ( user ) { return this . http . delete ( `/api/account/user/${ user . _id }` , { responseType : 'text' } ) ; } }