@@ -3,12 +3,13 @@ import { handleResponse, authHeader } from "../_helpers/service.helpers";
33import { API_URL } from "../_config/api.config" ;
44import { IgnoreArea } from "../types/ignoreArea" ;
55
6- const ENDPOINT_URL = "/test-variations"
6+ const ENDPOINT_URL = "/test-variations" ;
77
88export const testVariationService = {
99 getList,
1010 getDetails,
11- setIgnoreAreas
11+ setIgnoreAreas,
12+ setComment,
1213} ;
1314
1415function getList ( projectId : String ) : Promise < TestVariation [ ] > {
@@ -17,7 +18,10 @@ function getList(projectId: String): Promise<TestVariation[]> {
1718 headers : authHeader ( ) ,
1819 } ;
1920
20- return fetch ( `${ API_URL } ${ ENDPOINT_URL } ?projectId=${ projectId } ` , requestOptions ) . then ( handleResponse ) ;
21+ return fetch (
22+ `${ API_URL } ${ ENDPOINT_URL } ?projectId=${ projectId } ` ,
23+ requestOptions
24+ ) . then ( handleResponse ) ;
2125}
2226
2327function getDetails ( id : String ) : Promise < TestVariation > {
@@ -26,7 +30,9 @@ function getDetails(id: String): Promise<TestVariation> {
2630 headers : authHeader ( ) ,
2731 } ;
2832
29- return fetch ( `${ API_URL } ${ ENDPOINT_URL } /${ id } ` , requestOptions ) . then ( handleResponse ) ;
33+ return fetch ( `${ API_URL } ${ ENDPOINT_URL } /${ id } ` , requestOptions ) . then (
34+ handleResponse
35+ ) ;
3036}
3137
3238function setIgnoreAreas (
@@ -43,4 +49,16 @@ function setIgnoreAreas(
4349 `${ API_URL } ${ ENDPOINT_URL } /ignoreArea/${ variationId } ` ,
4450 requestOptions
4551 ) . then ( handleResponse ) ;
46- }
52+ }
53+
54+ function setComment ( id : string , comment : string ) : Promise < TestVariation > {
55+ const requestOptions = {
56+ method : "PUT" ,
57+ headers : { "Content-Type" : "application/json" , ...authHeader ( ) } ,
58+ body : JSON . stringify ( { comment } ) ,
59+ } ;
60+
61+ return fetch ( `${ API_URL } ${ ENDPOINT_URL } /comment/${ id } ` , requestOptions ) . then (
62+ handleResponse
63+ ) ;
64+ }
0 commit comments