Files
adastra_app/src/app/core/services/profiles.service.ts
T
2026-03-29 23:23:33 +02:00

29 lines
866 B
TypeScript

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ApiService } from '@services';
import { Profile } from '@models';
import { map } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
export class ProfilesService {
private _apiVersion = '/v2';
constructor(
private apiService: ApiService
) { }
get(username: string): Observable<Profile> {
return this.apiService.get(`${this._apiVersion}/profiles/${username}`)
.pipe(map((data: { profile: Profile }) => data.profile));
}
follow(username: string): Observable<Profile> {
return this.apiService.post(`${this._apiVersion}/profiles/${username}/follow`);
}
unfollow(username: string): Observable<Profile> {
return this.apiService.delete(`${this._apiVersion}/profiles/${username}/follow`);
}
}