aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/src/app/+admin/config/shared/config.service.ts
blob: 7c61fe9e7fc7c7964a4ea1c06525ab09d1911b37 (plain) (tree)
1
2
3
4
5
6
                                           

                                                 
                                                                                         
                                                                  
                                               






                                                                             




                                                                                          
                                                                            



                                                                                                
                                                                            

   
import { catchError } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model'
import { environment } from '../../../../environments/environment'
import { RestExtractor } from '../../../shared'

@Injectable()
export class ConfigService {
  private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config'

  constructor (
    private authHttp: HttpClient,
    private restExtractor: RestExtractor
  ) {}

  getCustomConfig () {
    return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom')
               .pipe(catchError(res => this.restExtractor.handleError(res)))
  }

  updateCustomConfig (data: CustomConfig) {
    return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data)
               .pipe(catchError(res => this.restExtractor.handleError(res)))
  }
}