-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathService.ts
More file actions
71 lines (60 loc) · 1.8 KB
/
Service.ts
File metadata and controls
71 lines (60 loc) · 1.8 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* @author Labs64 <netlicensing@labs64.com>
* @license Apache-2.0
* @link https://netlicensing.io
* @copyright 2017 Labs64 NetLicensing
*/
import type { AxiosInstance, AxiosResponse, Method } from 'axios';
import { Info, NlicResponse } from '@/types/api/response';
import type { ContextInstance } from '@/types/vo/Context';
export type AxiosRequestClient = Pick<AxiosInstance, 'request'>;
export interface RequestConfig {
onInfo?: (info: Info[]) => void;
onResponse?: (response: AxiosResponse) => void;
axiosInstance?: AxiosRequestClient;
}
export interface IService {
setAxiosInstance(this: void, instance: AxiosRequestClient): void;
getAxiosInstance(this: void): AxiosRequestClient;
// @deprecated use getResponse in RequestConfig
getLastHttpRequestInfo(this: void): AxiosResponse | null;
// @deprecated use getInfo in RequestConfig
getInfo(this: void): Info[];
/**
* this: void
* @param context
* @param endpoint
* @param data
* @param config
*/
get(
this: void,
context: ContextInstance,
endpoint: string,
data?: Record<string, unknown>,
config?: RequestConfig,
): Promise<AxiosResponse<NlicResponse>>;
post(
this: void,
context: ContextInstance,
endpoint: string,
data?: Record<string, unknown>,
config?: RequestConfig,
): Promise<AxiosResponse<NlicResponse>>;
delete(
this: void,
context: ContextInstance,
endpoint: string,
data?: Record<string, unknown>,
config?: RequestConfig,
): Promise<AxiosResponse<NlicResponse>>;
request(
this: void,
context: ContextInstance,
method: Method,
endpoint: string,
data?: Record<string, unknown>,
config?: RequestConfig,
): Promise<AxiosResponse<NlicResponse>>;
toQueryString<T extends Record<string, unknown>>(data: T): string;
}