25 lines
993 B
TypeScript
25 lines
993 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 { PARTNER_ACCOUNTS_API_ROUTES } from '../constants';
|
|
import { IAccountRawResponse, IAccountRequest, IAccountResponse } from '../models';
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class AccountsService {
|
|
constructor(private http: HttpClient) {}
|
|
|
|
private apiRoutes = PARTNER_ACCOUNTS_API_ROUTES;
|
|
|
|
getAll(): Observable<IPaginatedResponse<IAccountResponse>> {
|
|
return this.http.get<IPaginatedResponse<IAccountRawResponse>>(this.apiRoutes.list());
|
|
}
|
|
getSingle(accountId: string): Observable<IAccountResponse> {
|
|
return this.http.get<IAccountRawResponse>(this.apiRoutes.single(accountId));
|
|
}
|
|
|
|
update(accountId: string, userData: IAccountRequest): Observable<IAccountResponse> {
|
|
return this.http.patch<IAccountResponse>(this.apiRoutes.single(accountId), userData);
|
|
}
|
|
}
|