fshub-api 3.0.0 → 4.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/dist/api/FSHubApiRequest.d.ts +2 -2
- package/dist/api/FSHubApiRequest.d.ts.map +1 -1
- package/dist/api/FSHubApiRequest.js +16 -11
- package/dist/api/FSHubApiRequest.js.map +1 -1
- package/dist/api/airline/Airline_get.d.ts +2 -2
- package/dist/api/airline/Airline_get.d.ts.map +1 -1
- package/dist/api/airline/Airline_get.js +1 -1
- package/dist/api/airline/Airline_get.js.map +1 -1
- package/dist/api/airline/Airline_getAll.d.ts +2 -2
- package/dist/api/airline/Airline_getAll.d.ts.map +1 -1
- package/dist/api/airline/Airline_getAll.js +1 -1
- package/dist/api/airline/Airline_getAll.js.map +1 -1
- package/dist/api/airline/Airline_getAllFlightDeparturesAndArrivals.d.ts +2 -2
- package/dist/api/airline/Airline_getAllFlightDeparturesAndArrivals.d.ts.map +1 -1
- package/dist/api/airline/Airline_getAllFlightDeparturesAndArrivals.js +1 -1
- package/dist/api/airline/Airline_getAllFlightDeparturesAndArrivals.js.map +1 -1
- package/dist/api/airline/Airline_getAllFlightsArrivals.d.ts +2 -2
- package/dist/api/airline/Airline_getAllFlightsArrivals.d.ts.map +1 -1
- package/dist/api/airline/Airline_getAllFlightsArrivals.js +1 -1
- package/dist/api/airline/Airline_getAllFlightsArrivals.js.map +1 -1
- package/dist/api/airline/Airline_getAllFlightsDepartures.d.ts +2 -2
- package/dist/api/airline/Airline_getAllFlightsDepartures.d.ts.map +1 -1
- package/dist/api/airline/Airline_getAllFlightsDepartures.js +1 -1
- package/dist/api/airline/Airline_getAllFlightsDepartures.js.map +1 -1
- package/dist/api/airline/Airline_getAllScreenshots.d.ts +2 -2
- package/dist/api/airline/Airline_getAllScreenshots.d.ts.map +1 -1
- package/dist/api/airline/Airline_getAllScreenshots.js +2 -2
- package/dist/api/airline/Airline_getAllScreenshots.js.map +1 -1
- package/dist/api/airline/Airline_getFlights.d.ts +2 -2
- package/dist/api/airline/Airline_getFlights.d.ts.map +1 -1
- package/dist/api/airline/Airline_getFlights.js +1 -1
- package/dist/api/airline/Airline_getFlights.js.map +1 -1
- package/dist/api/airline/Airline_getPilotStats.d.ts +2 -2
- package/dist/api/airline/Airline_getPilotStats.d.ts.map +1 -1
- package/dist/api/airline/Airline_getPilotStats.js +1 -1
- package/dist/api/airline/Airline_getPilotStats.js.map +1 -1
- package/dist/api/airline/Airline_getPilots.d.ts +2 -2
- package/dist/api/airline/Airline_getPilots.d.ts.map +1 -1
- package/dist/api/airline/Airline_getPilots.js +1 -1
- package/dist/api/airline/Airline_getPilots.js.map +1 -1
- package/dist/api/airline/Airline_getStats.d.ts +2 -2
- package/dist/api/airline/Airline_getStats.d.ts.map +1 -1
- package/dist/api/airline/Airline_getStats.js +1 -1
- package/dist/api/airline/Airline_getStats.js.map +1 -1
- package/dist/api/flight/Flight_getFlightById.d.ts +2 -2
- package/dist/api/flight/Flight_getFlightById.d.ts.map +1 -1
- package/dist/api/flight/Flight_getFlightById.js +1 -1
- package/dist/api/flight/Flight_getFlightById.js.map +1 -1
- package/dist/api/flight/Flight_getFlightScreenshotsById.d.ts +2 -2
- package/dist/api/flight/Flight_getFlightScreenshotsById.d.ts.map +1 -1
- package/dist/api/flight/Flight_getFlightScreenshotsById.js +12 -3
- package/dist/api/flight/Flight_getFlightScreenshotsById.js.map +1 -1
- package/dist/api/flight/Flight_getFlights.d.ts +3 -0
- package/dist/api/flight/Flight_getFlights.d.ts.map +1 -0
- package/dist/api/flight/Flight_getFlights.js +57 -0
- package/dist/api/flight/Flight_getFlights.js.map +1 -0
- package/dist/api/flight/index.d.ts +2 -0
- package/dist/api/flight/index.d.ts.map +1 -1
- package/dist/api/flight/index.js +2 -0
- package/dist/api/flight/index.js.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_get.d.ts +2 -2
- package/dist/api/pilot/Pilot_get.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_get.js +1 -1
- package/dist/api/pilot/Pilot_get.js.map +1 -1
- package/dist/api/pilot/Pilot_getAll.d.ts +2 -2
- package/dist/api/pilot/Pilot_getAll.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_getAll.js +1 -1
- package/dist/api/pilot/Pilot_getAll.js.map +1 -1
- package/dist/api/pilot/Pilot_getAllAirlines.d.ts +2 -2
- package/dist/api/pilot/Pilot_getAllAirlines.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_getAllAirlines.js +1 -1
- package/dist/api/pilot/Pilot_getAllAirlines.js.map +1 -1
- package/dist/api/pilot/Pilot_getAllFlightDeparturesAndArrivals.d.ts +2 -2
- package/dist/api/pilot/Pilot_getAllFlightDeparturesAndArrivals.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_getAllFlightDeparturesAndArrivals.js +1 -1
- package/dist/api/pilot/Pilot_getAllFlightDeparturesAndArrivals.js.map +1 -1
- package/dist/api/pilot/Pilot_getAllFlights.d.ts +2 -2
- package/dist/api/pilot/Pilot_getAllFlights.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_getAllFlights.js +1 -1
- package/dist/api/pilot/Pilot_getAllFlights.js.map +1 -1
- package/dist/api/pilot/Pilot_getAllFlightsArrivals.d.ts +2 -2
- package/dist/api/pilot/Pilot_getAllFlightsArrivals.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_getAllFlightsArrivals.js +1 -1
- package/dist/api/pilot/Pilot_getAllFlightsArrivals.js.map +1 -1
- package/dist/api/pilot/Pilot_getAllFlightsDepartures.d.ts +2 -2
- package/dist/api/pilot/Pilot_getAllFlightsDepartures.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_getAllFlightsDepartures.js +1 -1
- package/dist/api/pilot/Pilot_getAllFlightsDepartures.js.map +1 -1
- package/dist/api/pilot/Pilot_getAllScreenshots.d.ts +2 -2
- package/dist/api/pilot/Pilot_getAllScreenshots.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_getAllScreenshots.js +2 -2
- package/dist/api/pilot/Pilot_getAllScreenshots.js.map +1 -1
- package/dist/api/pilot/Pilot_getCurrent.d.ts +2 -2
- package/dist/api/pilot/Pilot_getCurrent.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_getCurrent.js +1 -1
- package/dist/api/pilot/Pilot_getCurrent.js.map +1 -1
- package/dist/api/pilot/Pilot_getLatestFlight.d.ts +2 -2
- package/dist/api/pilot/Pilot_getLatestFlight.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_getLatestFlight.js +1 -1
- package/dist/api/pilot/Pilot_getLatestFlight.js.map +1 -1
- package/dist/api/pilot/Pilot_getStats.d.ts +2 -2
- package/dist/api/pilot/Pilot_getStats.d.ts.map +1 -1
- package/dist/api/pilot/Pilot_getStats.js +1 -1
- package/dist/api/pilot/Pilot_getStats.js.map +1 -1
- package/dist/index.d.ts +25 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +47 -34
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/release.ps1 +15 -0
- package/src/api/FSHubApiRequest.ts +8 -3
- package/src/api/airline/Airline_get.ts +2 -2
- package/src/api/airline/Airline_getAll.ts +2 -2
- package/src/api/airline/Airline_getAllFlightDeparturesAndArrivals.ts +2 -2
- package/src/api/airline/Airline_getAllFlightsArrivals.ts +2 -2
- package/src/api/airline/Airline_getAllFlightsDepartures.ts +2 -2
- package/src/api/airline/Airline_getAllScreenshots.ts +3 -3
- package/src/api/airline/Airline_getFlights.ts +2 -2
- package/src/api/airline/Airline_getPilotStats.ts +2 -2
- package/src/api/airline/Airline_getPilots.ts +2 -2
- package/src/api/airline/Airline_getStats.ts +2 -2
- package/src/api/flight/Flight_getFlightById.ts +2 -2
- package/src/api/flight/Flight_getFlightScreenshotsById.ts +12 -3
- package/src/api/flight/Flight_getFlights.ts +9 -0
- package/src/api/flight/index.ts +2 -0
- package/src/api/pilot/Pilot_get.ts +2 -2
- package/src/api/pilot/Pilot_getAll.ts +2 -2
- package/src/api/pilot/Pilot_getAllAirlines.ts +2 -2
- package/src/api/pilot/Pilot_getAllFlightDeparturesAndArrivals.ts +2 -2
- package/src/api/pilot/Pilot_getAllFlights.ts +2 -2
- package/src/api/pilot/Pilot_getAllFlightsArrivals.ts +2 -2
- package/src/api/pilot/Pilot_getAllFlightsDepartures.ts +2 -2
- package/src/api/pilot/Pilot_getAllScreenshots.ts +3 -3
- package/src/api/pilot/Pilot_getCurrent.ts +2 -2
- package/src/api/pilot/Pilot_getLatestFlight.ts +2 -2
- package/src/api/pilot/Pilot_getStats.ts +2 -2
- package/src/index.spec.ts +111 -77
- package/src/index.ts +20 -1
- package/src/types/index.ts +50 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fshub-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "TypeScript HTTP API wrapper library for FSHub REST API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -53,4 +53,4 @@
|
|
|
53
53
|
"axios": "^1.6.0",
|
|
54
54
|
"dotenv": "^17.2.1"
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|
package/release.ps1
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
param(
|
|
2
|
+
[Parameter(Mandatory=$true)]
|
|
3
|
+
[ValidateSet("patch", "minor", "major")]
|
|
4
|
+
[string]$Type
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
npm version $Type
|
|
8
|
+
npm run build
|
|
9
|
+
git add .
|
|
10
|
+
$version = npm pkg get version
|
|
11
|
+
$version = $version.Trim('"')
|
|
12
|
+
git commit -m "Release v$version"
|
|
13
|
+
git tag -a "v$version" -m "Release v$version"
|
|
14
|
+
git push origin master
|
|
15
|
+
git push origin --tags
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { AxiosResponse, AxiosError } from 'axios';
|
|
2
|
-
import { FSHubResponse, FSHubError, FSHubApi } from '../types';
|
|
2
|
+
import { FSHubRequestOptions, FSHubResponse, FSHubError, FSHubApi } from '../types';
|
|
3
3
|
|
|
4
|
-
export default async function FSHubApiRequest<T>(url: string, api: FSHubApi): Promise<FSHubResponse<T>> {
|
|
5
|
-
|
|
4
|
+
export default async function FSHubApiRequest<T>(url: string, api: FSHubApi, options?: FSHubRequestOptions): Promise<FSHubResponse<T>> {
|
|
5
|
+
let queryParams = '';
|
|
6
|
+
if (options) {
|
|
7
|
+
queryParams = `?cursor=${options.cursor}&limit=${options.limit}`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const response: FSHubResponse<T> = await api.axios.get(url + queryParams)
|
|
6
11
|
.then((res: AxiosResponse<FSHubResponse<T>>) => res.data)
|
|
7
12
|
.catch((err: AxiosError<FSHubError>) => {
|
|
8
13
|
if (err.response?.data.code === 404) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, Airline } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Airline_get(id: number, api: FSHubApi): Promise<Airline
|
|
4
|
+
export default async function Airline_get(id: number, api: FSHubApi): Promise<FSHubResponse<Airline>> {
|
|
5
5
|
const response: FSHubResponse<Airline> = await FSHubApiRequest(`airline/${id}`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, Airline } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Airline_getAll(api: FSHubApi): Promise<Airline[]
|
|
4
|
+
export default async function Airline_getAll(api: FSHubApi): Promise<FSHubResponse<Airline[]>> {
|
|
5
5
|
const response: FSHubResponse<Airline[]> = await FSHubApiRequest(`airline`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Flight, FSHubApi, FSHubResponse } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Airline_getAllFlightDeparturesAndArrivals(id: number, departureAirportCode: string, arrivalAirportCode: string, api: FSHubApi): Promise<Flight[]
|
|
4
|
+
export default async function Airline_getAllFlightDeparturesAndArrivals(id: number, departureAirportCode: string, arrivalAirportCode: string, api: FSHubApi): Promise<FSHubResponse<Flight[]>> {
|
|
5
5
|
const response: FSHubResponse<Flight[]> = await FSHubApiRequest(`airline/${id}/departure/${departureAirportCode}/arrival/${arrivalAirportCode}`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, Flight } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Airline_getAllFlightsArrivals(id: number, airportCode: string, api: FSHubApi): Promise<Flight[]
|
|
4
|
+
export default async function Airline_getAllFlightsArrivals(id: number, airportCode: string, api: FSHubApi): Promise<FSHubResponse<Flight[]>> {
|
|
5
5
|
const response: FSHubResponse<Flight[]> = await FSHubApiRequest(`airline/${id}/arrival/${airportCode}`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Flight, FSHubApi, FSHubResponse } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Airline_getAllFlightsDepartures(id: number, airportCode: string, api: FSHubApi): Promise<Flight[]
|
|
4
|
+
export default async function Airline_getAllFlightsDepartures(id: number, airportCode: string, api: FSHubApi): Promise<FSHubResponse<Flight[]>> {
|
|
5
5
|
const response: FSHubResponse<Flight[]> = await FSHubApiRequest(`airline/${id}/departure/${airportCode}`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, Screenshot } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Airline_getAllScreenshots(id: number, api: FSHubApi): Promise<Screenshot[]
|
|
4
|
+
export default async function Airline_getAllScreenshots(id: number, api: FSHubApi): Promise<FSHubResponse<Screenshot[]>> {
|
|
5
5
|
try {
|
|
6
6
|
const response: FSHubResponse<Screenshot[]> = await FSHubApiRequest(`airline/${id}/screenshot`, api);
|
|
7
7
|
|
|
8
|
-
return response
|
|
8
|
+
return response;
|
|
9
9
|
} catch (error) {
|
|
10
10
|
if (error instanceof Error && error.message === 'No records found') {
|
|
11
|
-
return [];
|
|
11
|
+
return { data: [] };
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
throw error;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, Flight } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Airline_getFlights(id: number, api: FSHubApi): Promise<Flight[]
|
|
4
|
+
export default async function Airline_getFlights(id: number, api: FSHubApi): Promise<FSHubResponse<Flight[]>> {
|
|
5
5
|
const response: FSHubResponse<Flight[]> = await FSHubApiRequest(`airline/${id}/flight`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, PilotStats } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Airline_getPilotStats(id: number, pilotId: number, api: FSHubApi): Promise<PilotStats
|
|
4
|
+
export default async function Airline_getPilotStats(id: number, pilotId: number, api: FSHubApi): Promise<FSHubResponse<PilotStats>> {
|
|
5
5
|
const response: FSHubResponse<PilotStats> = await FSHubApiRequest(`airline/${id}/pilot/${pilotId}/stats`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, Pilot } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Airline_getPilots(id: number, api: FSHubApi): Promise<Pilot[]
|
|
4
|
+
export default async function Airline_getPilots(id: number, api: FSHubApi): Promise<FSHubResponse<Pilot[]>> {
|
|
5
5
|
const response: FSHubResponse<Pilot[]> = await FSHubApiRequest(`airline/${id}/pilot`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AirlineStats, FSHubApi, FSHubResponse } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Airline_getStats(id: number, api: FSHubApi): Promise<AirlineStats
|
|
4
|
+
export default async function Airline_getStats(id: number, api: FSHubApi): Promise<FSHubResponse<AirlineStats>> {
|
|
5
5
|
const response: FSHubResponse<AirlineStats> = await FSHubApiRequest(`airline/${id}/stats`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { Flight, FSHubApi, FSHubResponse } from "../../types";
|
|
3
3
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
4
4
|
|
|
5
|
-
export default async function Flight_getFlightById(id: number, api: FSHubApi): Promise<Flight
|
|
5
|
+
export default async function Flight_getFlightById(id: number, api: FSHubApi): Promise<FSHubResponse<Flight>> {
|
|
6
6
|
const response: FSHubResponse<Flight> = await FSHubApiRequest(`flight/${id}`, api);
|
|
7
7
|
|
|
8
|
-
return response
|
|
8
|
+
return response;
|
|
9
9
|
}
|
|
@@ -2,8 +2,17 @@
|
|
|
2
2
|
import { Screenshot, FSHubApi, FSHubResponse } from "../../types";
|
|
3
3
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
4
4
|
|
|
5
|
-
export default async function Flight_getFlightScreenshotsById(id: number, api: FSHubApi): Promise<Screenshot[]
|
|
6
|
-
|
|
5
|
+
export default async function Flight_getFlightScreenshotsById(id: number, api: FSHubApi): Promise<FSHubResponse<Screenshot[]>> {
|
|
6
|
+
let response: FSHubResponse<Screenshot[]>;
|
|
7
|
+
try {
|
|
8
|
+
response = await FSHubApiRequest(`flight/${id}/screenshot`, api);
|
|
9
|
+
} catch (error: any) {
|
|
10
|
+
if (error.message === 'Not Found') {
|
|
11
|
+
return { data: [] };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
7
16
|
|
|
8
|
-
return response
|
|
17
|
+
return response;
|
|
9
18
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// https://fshub.io/api/v3/flight/{id}
|
|
2
|
+
import { Flight, FSHubApi, FSHubRequestOptions, FSHubResponse } from "../../types";
|
|
3
|
+
import FSHubApiRequest from "../FSHubApiRequest";
|
|
4
|
+
|
|
5
|
+
export default async function Flight_getFlights(api: FSHubApi, options?: FSHubRequestOptions): Promise<FSHubResponse<Flight[]>> {
|
|
6
|
+
const response: FSHubResponse<Flight[]> = await FSHubApiRequest(`flight`, api, options);
|
|
7
|
+
|
|
8
|
+
return response;
|
|
9
|
+
}
|
package/src/api/flight/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import Flight_getFlightById from './Flight_getFlightById';
|
|
2
2
|
import Flight_getFlightScreenshotsById from './Flight_getFlightScreenshotsById';
|
|
3
|
+
import Flight_getFlights from './Flight_getFlights';
|
|
3
4
|
|
|
4
5
|
export const Flight = {
|
|
5
6
|
getFlightById: Flight_getFlightById,
|
|
6
7
|
getFlightScreenshotsById: Flight_getFlightScreenshotsById,
|
|
8
|
+
getFlights: Flight_getFlights,
|
|
7
9
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Pilot, FSHubApi, FSHubResponse } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Pilot_get(id: number, api: FSHubApi): Promise<Pilot
|
|
4
|
+
export default async function Pilot_get(id: number, api: FSHubApi): Promise<FSHubResponse<Pilot>> {
|
|
5
5
|
const response: FSHubResponse<Pilot> = await FSHubApiRequest(`pilot/${id}`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Pilot, FSHubApi, FSHubResponse } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Pilot_getAll(api: FSHubApi): Promise<Pilot[]
|
|
4
|
+
export default async function Pilot_getAll(api: FSHubApi): Promise<FSHubResponse<Pilot[]>> {
|
|
5
5
|
const response: FSHubResponse<Pilot[]> = await FSHubApiRequest('pilot', api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Airline, FSHubApi, FSHubResponse } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Pilot_getAllAirlines(id: number, api: FSHubApi): Promise<Airline[]
|
|
4
|
+
export default async function Pilot_getAllAirlines(id: number, api: FSHubApi): Promise<FSHubResponse<Airline[]>> {
|
|
5
5
|
const response: FSHubResponse<Airline[]> = await FSHubApiRequest(`pilot/${id}/airline`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Flight, FSHubApi, FSHubResponse } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Pilot_getAllFlightDeparturesAndArrivals(id: number, departureAirportCode: string, arrivalAirportCode: string, api: FSHubApi): Promise<Flight[]
|
|
4
|
+
export default async function Pilot_getAllFlightDeparturesAndArrivals(id: number, departureAirportCode: string, arrivalAirportCode: string, api: FSHubApi): Promise<FSHubResponse<Flight[]>> {
|
|
5
5
|
const response: FSHubResponse<Flight[]> = await FSHubApiRequest(`pilot/${id}/flight/departure/${departureAirportCode}/arrival/${arrivalAirportCode}`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, Flight } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Pilot_getAllFlights(id: number, api: FSHubApi): Promise<Flight[]
|
|
4
|
+
export default async function Pilot_getAllFlights(id: number, api: FSHubApi): Promise<FSHubResponse<Flight[]>> {
|
|
5
5
|
const response: FSHubResponse<Flight[]> = await FSHubApiRequest(`pilot/${id}/flight`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, Flight } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Pilot_getAllFlightsArrivals(id: number, airportCode: string, api: FSHubApi): Promise<Flight[]
|
|
4
|
+
export default async function Pilot_getAllFlightsArrivals(id: number, airportCode: string, api: FSHubApi): Promise<FSHubResponse<Flight[]>> {
|
|
5
5
|
const response: FSHubResponse<Flight[]> = await FSHubApiRequest(`pilot/${id}/flight/arrival/${airportCode}`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Flight, FSHubApi, FSHubResponse } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Pilot_getAllFlightsDepartures(id: number, airportCode: string, api: FSHubApi): Promise<Flight[]
|
|
4
|
+
export default async function Pilot_getAllFlightsDepartures(id: number, airportCode: string, api: FSHubApi): Promise<FSHubResponse<Flight[]>> {
|
|
5
5
|
const response: FSHubResponse<Flight[]> = await FSHubApiRequest(`pilot/${id}/flight/departure/${airportCode}`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, Screenshot } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Pilot_getAllScreenshots(id: number, api: FSHubApi): Promise<Screenshot[]
|
|
4
|
+
export default async function Pilot_getAllScreenshots(id: number, api: FSHubApi): Promise<FSHubResponse<Screenshot[]>> {
|
|
5
5
|
try {
|
|
6
6
|
const response: FSHubResponse<Screenshot[]> = await FSHubApiRequest(`pilot/${id}/screenshot`, api);
|
|
7
7
|
|
|
8
|
-
return response
|
|
8
|
+
return response;
|
|
9
9
|
} catch (error) {
|
|
10
10
|
if (error instanceof Error && error.message === 'No records found') {
|
|
11
|
-
return [];
|
|
11
|
+
return { data: [] };
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
throw error;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CurrentPilot, FSHubApi, FSHubResponse } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Pilot_getCurrent(api: FSHubApi): Promise<CurrentPilot
|
|
4
|
+
export default async function Pilot_getCurrent(api: FSHubApi): Promise<FSHubResponse<CurrentPilot>> {
|
|
5
5
|
const response: FSHubResponse<CurrentPilot> = await FSHubApiRequest('user', api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, Flight } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Pilot_getLatestFlight(id: number, api: FSHubApi): Promise<Flight
|
|
4
|
+
export default async function Pilot_getLatestFlight(id: number, api: FSHubApi): Promise<FSHubResponse<Flight>> {
|
|
5
5
|
const response: FSHubResponse<Flight> = await FSHubApiRequest(`pilot/${id}/flight/latest`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FSHubApi, FSHubResponse, PilotStats } from "../../types";
|
|
2
2
|
import FSHubApiRequest from "../FSHubApiRequest";
|
|
3
3
|
|
|
4
|
-
export default async function Pilot_getStats(id: number, api: FSHubApi): Promise<PilotStats
|
|
4
|
+
export default async function Pilot_getStats(id: number, api: FSHubApi): Promise<FSHubResponse<PilotStats>> {
|
|
5
5
|
const response: FSHubResponse<PilotStats> = await FSHubApiRequest(`pilot/${id}/stats`, api);
|
|
6
6
|
|
|
7
|
-
return response
|
|
7
|
+
return response;
|
|
8
8
|
}
|