import { Injectable } from '@angular/core' ; import { HttpClient , HttpResponse } from '@angular/common/http' ; import { Observable } from 'rxjs' ; import { SERVER_API_URL } from 'app/app.constants' ; import { createRequestOption } from 'app/shared/util/request-util' ; import { IUser } from './user.model' ; @ Injectable ( { providedIn : 'root' } ) export class UserService { public resourceUrl = SERVER_API_URL + 'api/users' ; constructor ( private http ) { } create ( user ) { return this . http . post < IUser > ( this . resourceUrl , user , { observe : 'response' } ) ; } update ( user ) { return this . http . put < IUser > ( this . resourceUrl , user , { observe : 'response' } ) ; } find ( login ) { return this . http . get < IUser > ( `${ this . resourceUrl }/${ login }` , { observe : 'response' } ) ; } query ( req ? ) { const options = createRequestOption ( req ) ; return this . http . get < IUser [ ] > ( this . resourceUrl , { params : options , observe : 'response' } ) ; } delete ( login ) { return this . http . delete ( `${ this . resourceUrl }/${ login }` , { observe : 'response' } ) ; } authorities ( ) { return this . http . get < string [ ] > ( SERVER_API_URL + 'api/users/authorities' ) ; } }