FE: add episode seen service
This commit is contained in:
1 parent
7bf23432d6
commit
4fdb670510
1 file changed
+38
@@ -0,0 +1,38 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { EpisodeSeen } from '../../shared/models/episodeSeen.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class EpisodeSeenService {
|
||||
private backend_apiUrl = 'http://localhost:4000/api/v1';
|
||||
private apiAction = 'episode-seen';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
createEpisodeSeen(episodeId: number, dateSeen: Date, seenWith: string) {
|
||||
return this.http.post<EpisodeSeen>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}`,
|
||||
{
|
||||
episode_id: episodeId,
|
||||
date_seen: dateSeen,
|
||||
seen_with: seenWith,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// get episode-seen by episode Id
|
||||
getEpisodeSeenById(id: number) {
|
||||
return this.http.get<EpisodeSeen[]>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${id}`
|
||||
);
|
||||
}
|
||||
|
||||
removeEpisodeSeen(id: number) {
|
||||
return this.http.delete<any>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${id}`
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user