-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdata-structures.ts
98 lines (86 loc) · 2.22 KB
/
data-structures.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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* Copyright (c) Microblink Ltd. All rights reserved.
*/
export enum ApiType
{
Cloud = "cloud",
SelfHosted = "self-hosted"
}
export interface Configuration
{
/**
* API location.
*
* Default value for all API types is "http://localhost".
*
* If you're using Cloud API, check official documentation for exact
* location.
*/
apiLocation?: string;
/**
* Healthcheck endpoint used in `getHealthcheck` method to check if backend
* is available.
*
* This endpoint should return HTTP status 200 if everything is OK.
*
* Default value is "/v2/hc".
*/
healthcheckEndpoint?: string;
/**
* Default headers which are added to every request. This is useful for
* setting global authorization headers.
*
* If not set, request will not contain any provisional headers.
*/
headers?: { [ key: string ]: string };
/**
* Override default error messages for specific API type. It's not necessary
* to provide all error messages, but rather only those which should be
* modified.
*
* Default error messages are located in `src/service.cloud.ts` and
* `src/service.self-hosted.ts` files.
*
* Keep in mind that these messages are merged with generic error messages
* defined in `src/data-structures.ts` file.
*/
messages?: { [ key: string ]: string };
}
export const GenericMessages =
{
"GENERIC_ERROR": "There was an error during scan action.",
"UNKNOWN_ERROR": "Oops, something went wrong."
}
export interface ResponseError
{
code : string;
message : string;
}
export interface RequestPayload
{}
export interface ResponseRecognition
{
status : boolean;
response: HttpResponse;
error? : ResponseError;
}
export interface ResponseHealthcheck
{
status : boolean;
response? : HttpResponse;
}
export interface HttpResponse
{
data? : any;
headers : { [ key: string ]: string };
httpStatus : number;
}
export interface ApiService
{
getHealthcheckResponse(): Promise< HttpResponse >;
recognize(
endpoint: string,
payload : RequestPayload,
method? : string
): Promise< HttpResponse >;
}