-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathComments.ts
More file actions
44 lines (40 loc) · 1.56 KB
/
Comments.ts
File metadata and controls
44 lines (40 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Injectable, Inject } from '@angular/core';
import { Http } from '@angular/http';
// Need to import interfaces dependencies
// Bug TypeScript https://github.com/Microsoft/TypeScript/issues/5938
import { Observable } from 'rxjs/Observable';
import { RequestOptionsArgs } from '@angular/http/src/interfaces';
import { Response } from '@angular/http/src/static_response';
import { WpApiParent } from './Parent';
import { WpApiLoader } from './Loaders';
export interface IWpApiComments {
getList(options?: RequestOptionsArgs): Observable<Response>;
get(commentId: number, options?: RequestOptionsArgs): Observable<Response>;
create(body: any, options?: RequestOptionsArgs): Observable<Response>;
update(commentId: number, body: any, options?: RequestOptionsArgs): Observable<Response>;
delete(commentId: number, options?: RequestOptionsArgs): Observable<Response>;
}
@Injectable()
export class WpApiComments extends WpApiParent implements IWpApiComments {
constructor(
public wpApiLoader: WpApiLoader,
public http: Http
) {
super(wpApiLoader, http);
}
getList(options = {}) {
return this.httpGet(`/comments`, options)
}
get(commentId: number, options = {}) {
return this.httpGet(`/comments/${commentId}`, options)
}
create(body = {}, options = {}) {
return this.httpPost(`/comments`, body, options)
}
update(commentId: number, body = {}, options = {}) {
return this.httpPost(`/comments/${commentId}`, body, options)
}
delete(commentId: number, options = {}) {
return this.httpDelete(`/comments/${commentId}`, options)
}
}