privacy.service.ts 1.4KB

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 { IPrivacy } from 'app/shared/model/privacy.model';
  7. type EntityResponseType = HttpResponse<IPrivacy>;
  8. type EntityArrayResponseType = HttpResponse<IPrivacy[]>;
  9. @Injectable({ providedIn: 'root' })
  10. export class PrivacyService {
  11. public resourceUrl = SERVER_API_URL + 'api/privacies';
  12. constructor(private http: HttpClient) {}
  13. create(privacy: IPrivacy): Observable<EntityResponseType> {
  14. return this.http.post<IPrivacy>(this.resourceUrl, privacy, { observe: 'response' });
  15. }
  16. update(privacy: IPrivacy): Observable<EntityResponseType> {
  17. return this.http.put<IPrivacy>(this.resourceUrl, privacy, { observe: 'response' });
  18. }
  19. find(id: number): Observable<EntityResponseType> {
  20. return this.http.get<IPrivacy>(`${this.resourceUrl}/${id}`, { observe: 'response' });
  21. }
  22. query(req?: any): Observable<EntityArrayResponseType> {
  23. const options = createRequestOption(req);
  24. return this.http.get<IPrivacy[]>(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. }