-
Notifications
You must be signed in to change notification settings - Fork 67
/
Http.service.ts
32 lines (26 loc) 路 931 Bytes
/
Http.service.ts
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
import {IHttpValues, ITriggerService} from 'types/Test.types';
import Validator from 'utils/Validator';
import {HTTP_METHOD} from 'constants/Common.constants';
import HttpRequest from 'models/HttpRequest.model';
const HttpTriggerService = (): ITriggerService => ({
async getRequest(values) {
const {url, method, auth, headers, body, sslVerification} = values as IHttpValues;
return HttpRequest({url, method, auth, headers, body, sslVerification});
},
async validateDraft(draft): Promise<boolean> {
const {url, method} = draft as IHttpValues;
return Validator.required(url) && Validator.required(method);
},
getInitialValues(request) {
const {url, method, headers, body, auth, sslVerification} = request as HttpRequest;
return {
url,
auth,
method: method as HTTP_METHOD,
headers,
body,
sslVerification,
};
},
});
export default HttpTriggerService();