]>
Commit | Line | Data |
---|---|---|
d3e56c0c C |
1 | import { catchError } from 'rxjs/operators' |
2 | import { HttpClient } from '@angular/common/http' | |
3 | import { Injectable } from '@angular/core' | |
4 | import { environment } from '../../../environments/environment' | |
5 | import { RestExtractor, RestService } from '../rest' | |
6 | import { About } from '../../../../../shared/models/server' | |
7 | ||
8 | @Injectable() | |
9 | export class InstanceService { | |
10 | private static BASE_CONFIG_URL = environment.apiUrl + '/api/v1/config' | |
11 | private static BASE_SERVER_URL = environment.apiUrl + '/api/v1/server' | |
12 | ||
13 | constructor ( | |
14 | private authHttp: HttpClient, | |
15 | private restService: RestService, | |
16 | private restExtractor: RestExtractor | |
17 | ) { | |
18 | } | |
19 | ||
20 | getAbout () { | |
21 | return this.authHttp.get<About>(InstanceService.BASE_CONFIG_URL + '/about') | |
22 | .pipe(catchError(res => this.restExtractor.handleError(res))) | |
23 | } | |
24 | ||
4e9fa5b7 | 25 | contactAdministrator (fromEmail: string, fromName: string, subject: string, message: string) { |
d3e56c0c C |
26 | const body = { |
27 | fromEmail, | |
28 | fromName, | |
4e9fa5b7 | 29 | subject, |
d3e56c0c C |
30 | body: message |
31 | } | |
32 | ||
33 | return this.authHttp.post(InstanceService.BASE_SERVER_URL + '/contact', body) | |
34 | .pipe(catchError(res => this.restExtractor.handleError(res))) | |
35 | ||
36 | } | |
37 | } |