26 lines
957 B
TypeScript
26 lines
957 B
TypeScript
import { IPaginatedResponse } from '@/core/models/service.model';
|
|
import { HttpClient } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs';
|
|
import { SUPPLIERS_API_ROUTES } from '../constants';
|
|
import { ISupplierRawResponse, ISupplierRequest, ISupplierResponse } from '../models';
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class SuppliersService {
|
|
constructor(private http: HttpClient) {}
|
|
|
|
private apiRoutes = SUPPLIERS_API_ROUTES;
|
|
|
|
getAll(): Observable<IPaginatedResponse<ISupplierResponse>> {
|
|
return this.http.get<IPaginatedResponse<ISupplierRawResponse>>(this.apiRoutes.list());
|
|
}
|
|
|
|
getSingle(supplierId: string): Observable<ISupplierResponse> {
|
|
return this.http.get<ISupplierRawResponse>(this.apiRoutes.single(supplierId));
|
|
}
|
|
|
|
create(data: ISupplierRequest): Observable<ISupplierResponse> {
|
|
return this.http.post<ISupplierRawResponse>(this.apiRoutes.list(), data);
|
|
}
|
|
}
|