181 lines
4.2 KiB
Dart
181 lines
4.2 KiB
Dart
import 'dart:convert';
|
|
|
|
|
|
class Registration {
|
|
String? name;
|
|
String? factionSymbol;
|
|
String? role;
|
|
|
|
Registration({this.name,this.factionSymbol,this.role});
|
|
|
|
factory Registration.fromJson(Map<String, dynamic> json) {
|
|
return Registration(
|
|
name: json['name'],
|
|
factionSymbol: json['factionSymbol'],
|
|
role: json['role'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class Coordinates {
|
|
String? symbol;
|
|
String? type;
|
|
String? systemSymbol;
|
|
int? x;
|
|
int? y;
|
|
|
|
Coordinates({this.symbol, this.type, this.systemSymbol, this.x, this.y });
|
|
|
|
factory Coordinates.fromJson(Map<String, dynamic> json) {
|
|
return Coordinates(
|
|
symbol: json['symbol'],
|
|
type: json['type'],
|
|
systemSymbol: json['systemSymbol'],
|
|
x: json['x'],
|
|
y: json['y'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class Route {
|
|
Coordinates? departure;
|
|
Coordinates? destination;
|
|
String? arrival;
|
|
String? departureTime;
|
|
|
|
Route({this.departure, this.destination, this.arrival, this.departureTime});
|
|
|
|
factory Route.fromJson(Map<String, dynamic> json) {
|
|
return Route(
|
|
departure: Coordinates.fromJson(json['departure']),
|
|
destination: Coordinates.fromJson(json['destination']),
|
|
arrival: json['arrival'],
|
|
departureTime: json['departureTime'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class Nav {
|
|
String? systemSymbol;
|
|
String? waypointSymbol;
|
|
Route? route;
|
|
String? status;
|
|
String? flightMode;
|
|
|
|
Nav({this.systemSymbol, this.waypointSymbol, this.route, this.status, this.flightMode});
|
|
|
|
factory Nav.fromJson(Map<String, dynamic> json) {
|
|
return Nav(
|
|
systemSymbol: json['systemSymbol'],
|
|
waypointSymbol: json['waypointSymbol'],
|
|
route: Route.fromJson(json['route']),
|
|
status: json['status'],
|
|
flightMode: json['flightMode'],
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
class Inventory {
|
|
String? symbol;
|
|
String? name;
|
|
String? description;
|
|
int? units;
|
|
|
|
Inventory({this.symbol, this.name, this.description, this.units});
|
|
|
|
factory Inventory.fromJson(Map<String, dynamic> json) {
|
|
return Inventory(
|
|
symbol: json['symbol'],
|
|
name: json['name'],
|
|
description: json['description'],
|
|
units: json['units'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class Cargo {
|
|
int? capacity;
|
|
int? units;
|
|
List<Inventory>? inventory;
|
|
|
|
Cargo({this.capacity, this.units, this.inventory});
|
|
|
|
factory Cargo.fromJson(Map<String, dynamic> json) {
|
|
var inventoryList = json['inventory'] as List<dynamic>?;
|
|
List<Inventory>? parsedInventoryList;
|
|
if (inventoryList != null) {
|
|
parsedInventoryList = inventoryList
|
|
.map((item) => Inventory.fromJson(item))
|
|
.toList();
|
|
}
|
|
return Cargo(
|
|
capacity: json['capacity'],
|
|
units: json['units'],
|
|
inventory: parsedInventoryList,
|
|
);
|
|
}
|
|
}
|
|
|
|
class Consumed {
|
|
int? amount;
|
|
String? timestamp;
|
|
|
|
Consumed({this.amount, this.timestamp});
|
|
|
|
factory Consumed.fromJson(Map<String, dynamic> json) {
|
|
return Consumed(
|
|
amount: json['amount'],
|
|
timestamp: json['timestamp'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class Fuel {
|
|
int? current;
|
|
int? capacity;
|
|
Consumed? consumed;
|
|
|
|
Fuel({this.current, this.capacity, this.consumed});
|
|
|
|
factory Fuel.fromJson(Map<String, dynamic> json) {
|
|
return Fuel(
|
|
current: json['current'],
|
|
capacity: json['capacity'],
|
|
consumed: Consumed.fromJson(json['consumed']),
|
|
);
|
|
}
|
|
}
|
|
|
|
class ShipModel {
|
|
ShipModel({
|
|
this.symbol,
|
|
this.registration,
|
|
this.nav,
|
|
// this.crew,
|
|
// this.frame,
|
|
// this.reactor,
|
|
// this.engine,
|
|
// this.modules,
|
|
// this.mounts,
|
|
this.cargo,
|
|
this.fuel,
|
|
});
|
|
|
|
String? symbol;
|
|
Registration? registration;
|
|
Nav? nav;
|
|
Cargo? cargo;
|
|
Fuel? fuel;
|
|
|
|
factory ShipModel.fromJson(Map<String, dynamic> json) {
|
|
return ShipModel(
|
|
symbol: json['symbol'],
|
|
registration: Registration.fromJson(json['registration']),
|
|
nav: Nav.fromJson(json['nav']),
|
|
cargo: Cargo.fromJson(json['cargo']),
|
|
fuel: Fuel.fromJson(json['fuel']),
|
|
);
|
|
}
|
|
}
|