mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-01 11:19:32 -05:00

--------- Co-authored-by: Moritz Pflanzer <moritz@chickadee-engineering.com> Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { HttpClient } from '@angular/common/http'
|
|
import { Injectable } from '@angular/core'
|
|
import { Observable } from 'rxjs'
|
|
import {
|
|
PaperlessUserProfile,
|
|
SocialAccountProvider,
|
|
} 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/`,
|
|
{}
|
|
)
|
|
}
|
|
|
|
disconnectSocialAccount(id: number): Observable<number> {
|
|
return this.http.post<number>(
|
|
`${environment.apiBaseUrl}${this.endpoint}/disconnect_social_account/`,
|
|
{ id: id }
|
|
)
|
|
}
|
|
|
|
getSocialAccountProviders(): Observable<SocialAccountProvider[]> {
|
|
return this.http.get<SocialAccountProvider[]>(
|
|
`${environment.apiBaseUrl}${this.endpoint}/social_account_providers/`
|
|
)
|
|
}
|
|
}
|