1 import { of } from 'rxjs'
2 import { catchError, map } from 'rxjs/operators'
3 import { HttpClient } from '@angular/common/http'
4 import { Injectable } from '@angular/core'
5 import { RestExtractor } from '@app/core'
6 import { CustomPage } from '@shared/models'
7 import { environment } from '../../../../environments/environment'
10 export class CustomPageService {
11 static BASE_INSTANCE_HOMEPAGE_URL = environment.apiUrl + '/api/v1/custom-pages/homepage/instance'
14 private authHttp: HttpClient,
15 private restExtractor: RestExtractor
18 getInstanceHomepage () {
19 return this.authHttp.get<CustomPage>(CustomPageService.BASE_INSTANCE_HOMEPAGE_URL)
22 if (err.status === 404) {
23 return of({ content: '' })
26 this.restExtractor.handleError(err)
31 updateInstanceHomepage (content: string) {
32 return this.authHttp.put(CustomPageService.BASE_INSTANCE_HOMEPAGE_URL, { content })
34 map(this.restExtractor.extractDataBool),
35 catchError(err => this.restExtractor.handleError(err))