2019-01-10 10:12:41 +00:00
|
|
|
import { catchError } from 'rxjs/operators'
|
|
|
|
import { HttpClient } from '@angular/common/http'
|
|
|
|
import { Injectable } from '@angular/core'
|
|
|
|
import { environment } from '../../../environments/environment'
|
|
|
|
import { RestExtractor, RestService } from '../rest'
|
|
|
|
import { About } from '../../../../../shared/models/server'
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class InstanceService {
|
|
|
|
private static BASE_CONFIG_URL = environment.apiUrl + '/api/v1/config'
|
|
|
|
private static BASE_SERVER_URL = environment.apiUrl + '/api/v1/server'
|
|
|
|
|
|
|
|
constructor (
|
|
|
|
private authHttp: HttpClient,
|
|
|
|
private restService: RestService,
|
|
|
|
private restExtractor: RestExtractor
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
getAbout () {
|
|
|
|
return this.authHttp.get<About>(InstanceService.BASE_CONFIG_URL + '/about')
|
|
|
|
.pipe(catchError(res => this.restExtractor.handleError(res)))
|
|
|
|
}
|
|
|
|
|
2019-06-21 06:49:35 +00:00
|
|
|
contactAdministrator (fromEmail: string, fromName: string, subject: string, message: string) {
|
2019-01-10 10:12:41 +00:00
|
|
|
const body = {
|
|
|
|
fromEmail,
|
|
|
|
fromName,
|
2019-06-21 06:49:35 +00:00
|
|
|
subject,
|
2019-01-10 10:12:41 +00:00
|
|
|
body: message
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.authHttp.post(InstanceService.BASE_SERVER_URL + '/contact', body)
|
|
|
|
.pipe(catchError(res => this.restExtractor.handleError(res)))
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|