Files
psp_panel/src/app/domains/superAdmin/modules/users/services/accounts.service.ts
T

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 { ACCOUNTS_API_ROUTES } from '../constants';
import { IAccountRawResponse, IAccountRequest, IAccountResponse } from '../models';
@Injectable({ providedIn: 'root' })
export class AdminUserAccountsService {
constructor(private http: HttpClient) {}
private apiRoutes = ACCOUNTS_API_ROUTES;
getAll(userId: string): Observable<IPaginatedResponse<IAccountResponse>> {
return this.http.get<IPaginatedResponse<IAccountRawResponse>>(this.apiRoutes.list(userId));
}
getSingle(userId: string, accountId: string): Observable<IAccountResponse> {
return this.http.get<IAccountRawResponse>(this.apiRoutes.single(userId, accountId));
}
create(userId: string, data: IAccountRequest): Observable<IAccountResponse> {
return this.http.post<IAccountResponse>(this.apiRoutes.list(userId), data);
}
update(userId: string, accountId: string, data: IAccountRequest): Observable<IAccountResponse> {
return this.http.patch<IAccountResponse>(this.apiRoutes.single(userId, accountId), data);
}
}