-
Notifications
You must be signed in to change notification settings - Fork 34
/
interfaces.ts
93 lines (83 loc) · 1.93 KB
/
interfaces.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
export interface CharacterLocation {
name: string
url: string
}
export interface ResourceBase {
id: number
name: string
url: string
created: string
}
export interface Endpoints {
character: string
location: string
episode: string
}
export interface CharacterFilter {
name?: string
type?: string
species?: string
/**
* 'Dead' | 'Alive' | 'unknown'
*/
status?: string
/**
* 'Female' | 'Male' | 'Genderless' | 'unknown'
*/
gender?: string
page?: number
}
export interface LocationFilter extends Pick<CharacterFilter, 'name' | 'type' | 'page'> {
dimension?: string
}
export interface EpisodeFilter extends Pick<CharacterFilter, 'name' | 'page'> {
/**
* Filter by the given episode code.
* i.e: `{ episode: "S01E01" }`
*/
episode?: string
}
export interface Character extends ResourceBase {
status: 'Dead' | 'Alive' | 'unknown'
species: string
type: string
gender: 'Female' | 'Male' | 'Genderless' | 'unknown'
origin: CharacterLocation
location: CharacterLocation
image: string
episode: string[]
}
export interface Location extends ResourceBase {
type: string
dimension: string
residents: Character[]
}
export interface Episode extends ResourceBase {
air_date: string
episode: string
characters: string[]
}
export interface ApiResponse<T> {
/** The HTTP status code from the API response */
status: number
/** The HTTP status message from the API response */
statusMessage: string
/** The response that was provided by the API */
data: T
}
export interface Info<T> {
/**
* The API will automatically paginate the responses. You will receive up to `20` documents per page.
*/
info?: {
/** The length of the response */
count: number
/** The amount of pages */
pages: number
/** Link to the next page (if it exists) */
next: string | null
/** Link to the previous page (if it exists) */
prev: string | null
}
results?: T
}