29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
|
|
import { IPaginatedResponse } from '@/core/models/service.model';
|
||
|
|
import { HttpClient } from '@angular/common/http';
|
||
|
|
import { Injectable } from '@angular/core';
|
||
|
|
import { Observable } from 'rxjs';
|
||
|
|
import { GUILD_GOODS_API_ROUTES } from '../constants/apiRoutes/goods';
|
||
|
|
import { IGuildGoodRequest, IGuildGoodsRawResponse, IGuildGoodsResponse } from '../models';
|
||
|
|
|
||
|
|
@Injectable({ providedIn: 'root' })
|
||
|
|
export class GuildGoodsService {
|
||
|
|
constructor(private http: HttpClient) {}
|
||
|
|
|
||
|
|
private apiRoutes = GUILD_GOODS_API_ROUTES;
|
||
|
|
|
||
|
|
getAll(guildId: string): Observable<IPaginatedResponse<IGuildGoodsResponse>> {
|
||
|
|
return this.http.get<IPaginatedResponse<IGuildGoodsRawResponse>>(this.apiRoutes.list(guildId));
|
||
|
|
}
|
||
|
|
getSingle(guildId: string, id: string): Observable<IGuildGoodsResponse> {
|
||
|
|
return this.http.get<IGuildGoodsRawResponse>(this.apiRoutes.single(guildId, id));
|
||
|
|
}
|
||
|
|
|
||
|
|
create(guildId: string, data: IGuildGoodRequest): Observable<IGuildGoodsResponse> {
|
||
|
|
return this.http.post<IGuildGoodsResponse>(this.apiRoutes.list(guildId), data);
|
||
|
|
}
|
||
|
|
|
||
|
|
update(guildId: string, id: string, data: IGuildGoodRequest): Observable<IGuildGoodsResponse> {
|
||
|
|
return this.http.patch<IGuildGoodsResponse>(this.apiRoutes.single(guildId, id), data);
|
||
|
|
}
|
||
|
|
}
|