fshub-api 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/index.ts +132 -0
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fshub-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "TypeScript HTTP API wrapper library for FSHub REST API",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "src/index.ts",
|
|
6
6
|
"types": "src/types/index.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"import": "./
|
|
9
|
+
"import": "./src/index.ts",
|
|
10
10
|
"types": "./src/types/index.ts"
|
|
11
11
|
}
|
|
12
12
|
},
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import axios, { AxiosInstance } from 'axios';
|
|
2
|
+
import type{ Config, FSHubApi } from './types';
|
|
3
|
+
import { Api } from '@/api';
|
|
4
|
+
|
|
5
|
+
export * from './types';
|
|
6
|
+
|
|
7
|
+
export default class FSHubApiClass implements FSHubApi {
|
|
8
|
+
private readonly config: Config;
|
|
9
|
+
public readonly axios: AxiosInstance;
|
|
10
|
+
|
|
11
|
+
constructor(config: Config) {
|
|
12
|
+
if (!config.apiKey) {
|
|
13
|
+
throw new Error('FSHub API key is required!');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
this.config = config;
|
|
17
|
+
|
|
18
|
+
this.axios = axios.create({
|
|
19
|
+
baseURL: this.config.baseURL || 'https://fshub.io/api/v3/',
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
'X-Pilot-Token': this.config.apiKey,
|
|
23
|
+
...this.config.headers
|
|
24
|
+
},
|
|
25
|
+
timeout: this.config.timeout || 10000
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
this.Pilot_getCurrent = this.Pilot_getCurrent.bind(this);
|
|
29
|
+
this.Pilot_getAll = this.Pilot_getAll.bind(this);
|
|
30
|
+
this.Pilot_get = this.Pilot_get.bind(this);
|
|
31
|
+
this.Pilot_getLatestFlight = this.Pilot_getLatestFlight.bind(this);
|
|
32
|
+
this.Pilot_getAllFlights = this.Pilot_getAllFlights.bind(this);
|
|
33
|
+
this.Pilot_getAllAirlines = this.Pilot_getAllAirlines.bind(this);
|
|
34
|
+
this.Pilot_getStats = this.Pilot_getStats.bind(this);
|
|
35
|
+
this.Pilot_getAllFlightsDepartures = this.Pilot_getAllFlightsDepartures.bind(this);
|
|
36
|
+
this.Pilot_getAllFlightsArrivals = this.Pilot_getAllFlightsArrivals.bind(this);
|
|
37
|
+
this.Pilot_getAllFlightDeparturesAndArrivals = this.Pilot_getAllFlightDeparturesAndArrivals.bind(this);
|
|
38
|
+
this.Pilot_getAllScreenshots = this.Pilot_getAllScreenshots.bind(this);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public async Pilot_getCurrent() {
|
|
42
|
+
return await Api.pilot.getCurrent(this);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async Pilot_getAll() {
|
|
46
|
+
return await Api.pilot.getAll(this);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public async Pilot_get(id: number) {
|
|
50
|
+
return await Api.pilot.get(id, this);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public async Pilot_getLatestFlight(id: number) {
|
|
54
|
+
return await Api.pilot.getLatestFlight(id, this);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public async Pilot_getAllFlights(id: number) {
|
|
58
|
+
return await Api.pilot.getAllFlights(id, this);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public async Pilot_getAllAirlines(id: number) {
|
|
62
|
+
return await Api.pilot.getAllAirlines(id, this);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public async Pilot_getStats(id: number) {
|
|
66
|
+
return await Api.pilot.getStats(id, this);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public async Pilot_getAllFlightsDepartures(id: number, airportCode: string) {
|
|
70
|
+
return await Api.pilot.getAllFlightsDepartures(id, airportCode, this);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public async Pilot_getAllFlightsArrivals(id: number, airportCode: string) {
|
|
74
|
+
return await Api.pilot.getAllFlightsArrivals(id, airportCode, this);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public async Pilot_getAllFlightDeparturesAndArrivals(id: number, departureAirportCode: string, arrivalAirportCode: string) {
|
|
78
|
+
return await Api.pilot.getAllFlightDeparturesAndArrivals(id, departureAirportCode, arrivalAirportCode, this);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public async Pilot_getAllScreenshots(id: number) {
|
|
82
|
+
return await Api.pilot.getAllScreenshots(id, this);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public async Airline_getAll() {
|
|
86
|
+
return await Api.airline.getAll(this);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public async Airline_get(id: number) {
|
|
90
|
+
return await Api.airline.get(id, this);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public async Airline_getPilots(id: number) {
|
|
94
|
+
return await Api.airline.getPilots(id, this);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public async Airline_getPilotStats(id: number, pilotId: number) {
|
|
98
|
+
return await Api.airline.getPilotStats(id, pilotId, this);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public async Airline_getFlights(id: number) {
|
|
102
|
+
return await Api.airline.getFlights(id, this);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public async Airline_getAllFlightsDepartures(id: number, airportCode: string) {
|
|
106
|
+
return await Api.airline.getAllFlightsDepartures(id, airportCode, this);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public async Airline_getAllFlightsArrivals(id: number, airportCode: string) {
|
|
110
|
+
return await Api.airline.getAllFlightsArrivals(id, airportCode, this);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public async Airline_getAllFlightDeparturesAndArrivals(id: number, departureAirportCode: string, arrivalAirportCode: string) {
|
|
114
|
+
return await Api.airline.getAllFlightDeparturesAndArrivals(id, departureAirportCode, arrivalAirportCode, this);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public async Airline_getAllScreenshots(id: number) {
|
|
118
|
+
return await Api.airline.getAllScreenshots(id, this);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public async Airline_getStats(id: number) {
|
|
122
|
+
return await Api.airline.getStats(id, this);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public async Flight_getFlightById(id: number) {
|
|
126
|
+
return await Api.flight.getFlightById(id, this);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public async Flight_getFlightScreenshotsById(id: number) {
|
|
130
|
+
return await Api.flight.getFlightScreenshotsById(id, this);
|
|
131
|
+
}
|
|
132
|
+
}
|