import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Post } from '../core/entities';

@Injectable()
export class PostService {

	constructor(private http: HttpClient) {}

	getPost(postKey: string): Observable<Post> {
		return this.http.get<Post>(`/api/posts/${postKey}`);
	}

	deletePost(postToDelete: Post): Observable<any> {
		return this.http.delete(`/api/posts/${postToDelete.key}`);
	}
}
