-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZeokkuAPI.js
55 lines (42 loc) · 1.17 KB
/
ZeokkuAPI.js
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
45
46
47
48
49
50
51
52
53
54
55
import axios from "axios";
//make TS typings ZeokkuAPI.d.ts
/*
params = { a: 1, b: 'b' };
path = 'C:/pathFolder'
console.log('get', (path, { params }));
//path is not printed for some reason
add hcaptcha for codes redeem
*/
const http = axios.create({
baseURL: "https://api.zeokku.com/",
responseType: "json",
headers: {
post: {
"Content-Type": "application/json",
},
//Cookie: objToQuery(cookieContainer, "; ", "="),
},
withCredentials: true,
});
let baseHandler = {
get(base, _interface, proxy) {
//return Reflect.get(...arguments);
let interfaceHandler = {
get({ _interface }, _method) {
return ({ version = 1, params = {}, ...body } = {}) => {
let path = `/${_interface}/${_method}/v${version}`;
if (_method.startsWith("get")) {
Object.assign(params, body);
return http.get(path, { params });
} else {
return http.post(path, body, { params });
}
};
},
};
return new Proxy({ _interface }, interfaceHandler);
},
};
export default ZeokkuAPI = new Proxy({}, baseHandler);
//usage:
//ZeokkuAPI.IPlayerService.login({ username, password })