import { Injectable , Inject } from '@angular/core' ; import * as _ from 'lodash' ; import { URL_STRING } from './InjectUrlString' ; import { HttpClient } from '@angular/common/http' ; @ Injectable ( { providedIn : 'root' } ) export class BaseHttpService { constructor ( public https , @ Inject ( URL_STRING ) public baseURL ) { } header ( params ? , url ? ) { return this . https . head ( url ) ; } get ( params , url ? ) { let _objectBool = _ . isObject ( params ) ; let _baseUrl = url || this . baseURL ; let _url = ( ! _objectBool && params !== undefined && params !== null ) ? `${ _baseUrl }/${ params }` : _baseUrl ; return _objectBool ? this . https . get ( _url , { params : params } ) : this . https . get ( _url ) ; } getAll ( url ? ) { let _url = url || this . baseURL ; return this . https . get ( _url ) ; } create ( params , url ? , header ? ) { let _url = url || this . baseURL ; return this . https . post ( _url , params ) ; } update ( params , url ? , header ? ) { let _url = url || this . baseURL ; return this . https . put ( _url , params ) ; } delete ( params ? , url ? , header ? ) { return this . https . delete ( url ) ; } deleteObject ( params ? , url ? , header ? ) { return this . https . delete ( url ) ; } }