@flybywiresim/api-client
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -18,2 +18,12 @@ export declare class MetarResponse { | ||
} | ||
export declare class AirportResponse { | ||
icao: string; | ||
type: string; | ||
name: string; | ||
lat: number; | ||
lon: number; | ||
elevation: number; | ||
continent: string; | ||
country: string; | ||
} | ||
export declare class TelexConnection { | ||
@@ -92,3 +102,3 @@ id: string; | ||
static update(status: AircraftStatus): Promise<TelexConnection>; | ||
static disconnect(status: AircraftStatus): Promise<void>; | ||
static disconnect(): Promise<void>; | ||
static sendMessage(recipientFlight: string, message: string): Promise<TelexMessage>; | ||
@@ -99,2 +109,3 @@ static fetchMessages(): Promise<TelexMessage[]>; | ||
static findConnection(flightNumber: string): Promise<TelexConnection>; | ||
static countConnections(): Promise<number>; | ||
private static buildBody; | ||
@@ -104,1 +115,4 @@ private static buildToken; | ||
} | ||
export declare class Airport { | ||
static get(icao: string): Promise<AirportResponse>; | ||
} |
@@ -16,3 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Telex = exports.Taf = exports.Atis = exports.Metar = exports.NXApi = exports.TelexNotConnectedError = exports.HttpError = void 0; | ||
exports.Airport = exports.Telex = exports.Taf = exports.Atis = exports.Metar = exports.NXApi = exports.TelexNotConnectedError = exports.HttpError = void 0; | ||
var HttpError = /** @class */ (function (_super) { | ||
@@ -146,3 +146,3 @@ __extends(HttpError, _super); | ||
}; | ||
Telex.disconnect = function (status) { | ||
Telex.disconnect = function () { | ||
Telex.connectionOrThrow(); | ||
@@ -231,2 +231,12 @@ var headers = { | ||
}; | ||
Telex.countConnections = function () { | ||
var url = new URL("/txcxn/_count", NXApi.url); | ||
return fetch(url.href, { method: "GET" }) | ||
.then(function (response) { | ||
if (!response.ok) { | ||
throw new HttpError(response.status); | ||
} | ||
return response.json(); | ||
}); | ||
}; | ||
Telex.buildBody = function (status) { | ||
@@ -259,1 +269,20 @@ return { | ||
exports.Telex = Telex; | ||
var Airport = /** @class */ (function () { | ||
function Airport() { | ||
} | ||
Airport.get = function (icao) { | ||
if (!icao) { | ||
throw new Error("No ICAO provided"); | ||
} | ||
var url = new URL("/api/v1/airport/" + icao, NXApi.url); | ||
return fetch(url.href) | ||
.then(function (response) { | ||
if (!response.ok) { | ||
throw new HttpError(response.status); | ||
} | ||
return response.json(); | ||
}); | ||
}; | ||
return Airport; | ||
}()); | ||
exports.Airport = Airport; |
{ | ||
"name": "@flybywiresim/api-client", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "Client library for the FlyByWire Simulations API", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
14333
398
13