mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-01 11:19:32 -05:00
35 lines
921 B
TypeScript
35 lines
921 B
TypeScript
import { HttpClient } from '@angular/common/http'
|
|
import { Injectable } from '@angular/core'
|
|
import { Observable } from 'rxjs'
|
|
import { PaperlessUserProfile } from '../data/user-profile'
|
|
import { environment } from 'src/environments/environment'
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class ProfileService {
|
|
private endpoint = 'profile'
|
|
|
|
constructor(private http: HttpClient) {}
|
|
|
|
get(): Observable<PaperlessUserProfile> {
|
|
return this.http.get<PaperlessUserProfile>(
|
|
`${environment.apiBaseUrl}${this.endpoint}/`
|
|
)
|
|
}
|
|
|
|
update(profile: PaperlessUserProfile): Observable<PaperlessUserProfile> {
|
|
return this.http.patch<PaperlessUserProfile>(
|
|
`${environment.apiBaseUrl}${this.endpoint}/`,
|
|
profile
|
|
)
|
|
}
|
|
|
|
generateAuthToken(): Observable<string> {
|
|
return this.http.post<string>(
|
|
`${environment.apiBaseUrl}${this.endpoint}/generate_auth_token/`,
|
|
{}
|
|
)
|
|
}
|
|
}
|