import { Injectable }       from '@angular/core'
import { HttpClient }             from '@angular/common/http'

import { SharedService }    from './svc.shared'
import { HelperService }    from './svc.helper'

import { PageType }         from '../types/page'


@Injectable()
export class PageBlockService {
	
	constructor(
        private http: HttpClient,
        private _shared: SharedService,
        private _helper: HelperService
    ) { }

    api: string = this._helper.server
    credentials: string = this._helper.credentials

    /**
     * Returns static block content as Object based on identifier
     * 
     * @param identifier: string
     */
    getBlockContent(identifier: string): Promise<any> {
		return this.http.get(this.api + 'feed/get/static' + this.credentials + '&identifier=' + identifier)
			.toPromise()
			.then((response: any) => {
					return response.data as PageType
			})
			.catch();
    }



}
