Project

General

Profile

1
import { GenericRestService } from './../generic-rest.service';
2
import { AuthService } from './../auth.service';
3
import { environment } from 'src/environments/environment';
4
import { HttpClient } from '@angular/common/http';
5
import { IPowerClient } from './../../models/ipower-client.interface';
6
import { Injectable } from '@angular/core';
7
import { Observable } from 'rxjs';
8

    
9
@Injectable({
10
  providedIn: 'root'
11
})
12
export class IpowerClientsService extends GenericRestService<IPowerClient> {
13

    
14
  constructor(private http: HttpClient, private authService: AuthService) {
15
    super(`${environment.baseApiUrl}${environment.apiUrl.usersWs}/users`, http);
16
  }
17

    
18
  public getClientsByUser(): Observable<IPowerClient[]> {
19
    return this.http.get<IPowerClient[]>(this.baseUrl + '/clientsByUser', {
20
      params: {
21
        userId: '' + this.authService.userDetails.id
22
      }
23
    });
24
  }
25

    
26
  public getClientsByNameDistinct(name: string): Observable<IPowerClient[]> {
27
    return this.http.get<IPowerClient[]>(this.baseUrl + '/clientsByName', {
28
      params: {
29
        name: name,
30
        userId: '' + this.authService.userDetails.id
31
      }
32
    });
33
  }
34

    
35
  public getClientsByNameOnly(name: string): Observable<IPowerClient[]> {
36
    return this.http.get<IPowerClient[]>(this.baseUrl + '/clientsByNameOnly', {
37
      params: {
38
        name: name
39
      }
40
    });
41
  }
42

    
43
  public getClientsByCodeDistinct(code: string): Observable<IPowerClient[]> {
44
    return this.http.get<IPowerClient[]>(this.baseUrl + '/clientsByCode', {
45
      params: {
46
        code: code,
47
        userId: '' + /*'CY136279'*/ this.authService.userDetails.id
48
      }
49
    });
50
  }
51

    
52
  public getClientsByCodeOnly(code: string): Observable<IPowerClient[]> {
53
    return this.http.get<IPowerClient[]>(this.baseUrl + '/clientsByCodeOnly', {
54
      params: {
55
        code: code
56
      }
57
    });
58
  }
59

    
60
  public getClientById(id: number): Observable<IPowerClient> {
61
    return this.http.get<IPowerClient>(this.baseUrl + '/clientById', {
62
      params: {
63
        id: '' + id,
64
        userId: '' + this.authService.userDetails.id
65
      }
66
    });
67
  }
68
}
(14-14/20)