26 lines
912 B
TypeScript
26 lines
912 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 { STORES_API_ROUTES } from '../constants';
|
|
import { IStoreRawResponse, IStoreRequest, IStoreResponse } from '../models';
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class StoresService {
|
|
constructor(private http: HttpClient) {}
|
|
|
|
private apiRoutes = STORES_API_ROUTES;
|
|
|
|
getAll(): Observable<IPaginatedResponse<IStoreResponse>> {
|
|
return this.http.get<IPaginatedResponse<IStoreRawResponse>>(this.apiRoutes.list());
|
|
}
|
|
|
|
getSingle(storeId: string): Observable<IStoreResponse> {
|
|
return this.http.get<IStoreRawResponse>(this.apiRoutes.single(storeId));
|
|
}
|
|
|
|
create(data: IStoreRequest): Observable<IStoreResponse> {
|
|
return this.http.post<IStoreRawResponse>(this.apiRoutes.list(), data);
|
|
}
|
|
}
|