import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { environment } from 'src/environments/environment'; import { BookChapterItem } from './_models/book-chapter-item'; import { BookInfo } from './_models/book-info'; export interface BookPage { bookTitle: string; styles: string; html: string; } @Injectable({ providedIn: 'root' }) export class BookService { baseUrl = environment.apiUrl; constructor(private http: HttpClient) { } getFontFamilies() { return ['default', 'EBGaramond', 'Fira Sans', 'Lato', 'Libre Baskerville', 'Merriweather', 'Nanum Gothic', 'RocknRoll One']; } getBookChapters(chapterId: number) { return this.http.get>(this.baseUrl + 'book/' + chapterId + '/chapters'); } getBookPage(chapterId: number, page: number) { return this.http.get(this.baseUrl + 'book/' + chapterId + '/book-page?page=' + page, {responseType: 'text' as 'json'}); } getBookInfo(chapterId: number) { return this.http.get(this.baseUrl + 'book/' + chapterId + '/book-info'); } getBookPageUrl(chapterId: number, page: number) { return this.baseUrl + 'book/' + chapterId + '/book-page?page=' + page; } }