user-profile.service.ts 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Injectable } from '@angular/core';
  2. import { HttpClient, HttpResponse } from '@angular/common/http';
  3. import { Observable } from 'rxjs';
  4. import { SERVER_API_URL } from 'app/app.constants';
  5. import { createRequestOption } from 'app/shared';
  6. import { IUserProfile } from 'app/shared/model/user-profile.model';
  7. type EntityResponseType = HttpResponse<IUserProfile>;
  8. type EntityArrayResponseType = HttpResponse<IUserProfile[]>;
  9. @Injectable({ providedIn: 'root' })
  10. export class UserProfileService {
  11. public resourceUrl = SERVER_API_URL + 'api/user-profiles';
  12. constructor(private http: HttpClient) {}
  13. create(userProfile: IUserProfile): Observable<EntityResponseType> {
  14. return this.http.post<IUserProfile>(this.resourceUrl, userProfile, { observe: 'response' });
  15. }
  16. update(userProfile: IUserProfile): Observable<EntityResponseType> {
  17. return this.http.put<IUserProfile>(this.resourceUrl, userProfile, { observe: 'response' });
  18. }
  19. find(id: number): Observable<EntityResponseType> {
  20. return this.http.get<IUserProfile>(`${this.resourceUrl}/${id}`, { observe: 'response' });
  21. }
  22. query(req?: any): Observable<EntityArrayResponseType> {
  23. const options = createRequestOption(req);
  24. return this.http.get<IUserProfile[]>(this.resourceUrl, { params: options, observe: 'response' });
  25. }
  26. delete(id: number): Observable<HttpResponse<any>> {
  27. return this.http.delete<any>(`${this.resourceUrl}/${id}`, { observe: 'response' });
  28. }
  29. }