7 changed files with 359 additions and 3 deletions
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
kind: pipeline |
||||
name: default |
||||
|
||||
steps: |
||||
- name: test |
||||
image: google/dart:2 |
||||
commands: |
||||
- pub get |
||||
- dartanalyzer --fatal-infos --fatal-warnings . |
||||
- dartfmt -n --set-exit-if-changed . |
||||
- pub run test |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
import 'package:db_construction_site/models/region.dart'; |
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
import 'connection_type.dart'; |
||||
|
||||
part 'connection.g.dart'; |
||||
|
||||
@JsonSerializable(createToJson: false) |
||||
class Connection { |
||||
final String id; |
||||
final String name; |
||||
@JsonKey(name: "von") |
||||
final String origin; |
||||
@JsonKey(name: "nach") |
||||
final String destination; |
||||
@JsonKey(name: "kbnr") |
||||
final String courseBookNumber; |
||||
@JsonKey(name: "verlauf") |
||||
final List<String> stops; |
||||
@JsonKey(name: "via") |
||||
final String via; |
||||
final DateTime timestamp; |
||||
@JsonKey(name: "verfall") |
||||
final DateTime expiryDate; |
||||
@JsonKey(name: "verbindung") |
||||
final ConnectionType type; |
||||
@JsonKey(name: "land") |
||||
final Region region; |
||||
final String url; |
||||
@JsonKey(name: "ics") |
||||
final String icsUrl; |
||||
@JsonKey(name: "doc") |
||||
final String documentUrl; |
||||
|
||||
const Connection({ |
||||
this.id, |
||||
this.name, |
||||
this.origin, |
||||
this.destination, |
||||
this.courseBookNumber, |
||||
this.stops, |
||||
this.via, |
||||
this.timestamp, |
||||
this.expiryDate, |
||||
this.type, |
||||
this.region, |
||||
this.url, |
||||
this.icsUrl, |
||||
this.documentUrl, |
||||
}); |
||||
|
||||
factory Connection.fromJson(Map<String, dynamic> json) => |
||||
_$ConnectionFromJson(json); |
||||
} |
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'connection.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
Connection _$ConnectionFromJson(Map<String, dynamic> json) { |
||||
return Connection( |
||||
id: json['id'] as String, |
||||
name: json['name'] as String, |
||||
origin: json['von'] as String, |
||||
destination: json['nach'] as String, |
||||
courseBookNumber: json['kbnr'] as String, |
||||
stops: (json['verlauf'] as List)?.map((e) => e as String)?.toList(), |
||||
via: json['via'] as String, |
||||
timestamp: json['timestamp'] == null |
||||
? null |
||||
: DateTime.parse(json['timestamp'] as String), |
||||
expiryDate: json['verfall'] == null |
||||
? null |
||||
: DateTime.parse(json['verfall'] as String), |
||||
type: _$enumDecodeNullable(_$ConnectionTypeEnumMap, json['verbindung']), |
||||
region: _$enumDecodeNullable(_$RegionEnumMap, json['land']), |
||||
url: json['url'] as String, |
||||
icsUrl: json['ics'] as String, |
||||
documentUrl: json['doc'] as String, |
||||
); |
||||
} |
||||
|
||||
T _$enumDecode<T>( |
||||
Map<T, dynamic> enumValues, |
||||
dynamic source, { |
||||
T unknownValue, |
||||
}) { |
||||
if (source == null) { |
||||
throw ArgumentError('A value must be provided. Supported values: ' |
||||
'${enumValues.values.join(', ')}'); |
||||
} |
||||
|
||||
final value = enumValues.entries |
||||
.singleWhere((e) => e.value == source, orElse: () => null) |
||||
?.key; |
||||
|
||||
if (value == null && unknownValue == null) { |
||||
throw ArgumentError('`$source` is not one of the supported values: ' |
||||
'${enumValues.values.join(', ')}'); |
||||
} |
||||
return value ?? unknownValue; |
||||
} |
||||
|
||||
T _$enumDecodeNullable<T>( |
||||
Map<T, dynamic> enumValues, |
||||
dynamic source, { |
||||
T unknownValue, |
||||
}) { |
||||
if (source == null) { |
||||
return null; |
||||
} |
||||
return _$enumDecode<T>(enumValues, source, unknownValue: unknownValue); |
||||
} |
||||
|
||||
const _$ConnectionTypeEnumMap = { |
||||
ConnectionType.longDistance: 'fern', |
||||
ConnectionType.regional: 'regional', |
||||
ConnectionType.sBahn: 'sbahn', |
||||
}; |
||||
|
||||
const _$RegionEnumMap = { |
||||
Region.lowerSaxonyBremen: 'niedersachen-bremen', |
||||
Region.north: 'norden', |
||||
Region.mecklenburgWesternPomerania: 'mvp', |
||||
Region.berlinBrandenburg: 'berlin-bb', |
||||
Region.saxonyAnhalt: 'sachsen-anhalt', |
||||
Region.saxony: 'sachsen', |
||||
Region.bavaria: 'bayern', |
||||
Region.thuringia: 'thueringen', |
||||
Region.badenWuerttemberg: 'baden-w', |
||||
Region.rhinelandPalatinate: 'rheinland-pfalz', |
||||
Region.hesse: 'hessen', |
||||
Region.northrhineWestphalia: 'nrw', |
||||
}; |
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
enum ConnectionType { |
||||
@JsonValue("fern") |
||||
longDistance, |
||||
@JsonValue("regional") |
||||
regional, |
||||
@JsonValue("sbahn") |
||||
sBahn, |
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
enum Region { |
||||
/// Lower Saxony and Bremen |
||||
@JsonValue("niedersachen-bremen") |
||||
lowerSaxonyBremen, |
||||
|
||||
/// Schleswig Holstein |
||||
@JsonValue("norden") |
||||
north, |
||||
|
||||
/// Mecklenburg Western Pomerania |
||||
@JsonValue("mvp") |
||||
mecklenburgWesternPomerania, |
||||
|
||||
/// Berlin and Brandenburg |
||||
@JsonValue("berlin-bb") |
||||
berlinBrandenburg, |
||||
|
||||
/// Saxony-Anhalt |
||||
@JsonValue("sachsen-anhalt") |
||||
saxonyAnhalt, |
||||
|
||||
/// Saxony |
||||
@JsonValue("sachsen") |
||||
saxony, |
||||
|
||||
/// Bavaria |
||||
@JsonValue("bayern") |
||||
bavaria, |
||||
|
||||
/// Thuringia |
||||
@JsonValue("thueringen") |
||||
thuringia, |
||||
|
||||
/// Baden-Württemberg |
||||
@JsonValue("baden-w") |
||||
badenWuerttemberg, |
||||
|
||||
/// Rhineland Palatinate |
||||
@JsonValue("rheinland-pfalz") |
||||
rhinelandPalatinate, |
||||
|
||||
/// Hesse |
||||
@JsonValue("hessen") |
||||
hesse, |
||||
|
||||
/// Northrhine-Westphalia |
||||
@JsonValue("nrw") |
||||
northrhineWestphalia |
||||
} |
Loading…
Reference in new issue