mirror of
https://gitlab.com/TheOneWithTheBraid/dart_pkpass.git
synced 2025-07-06 05:18:47 +00:00
chore: initial commit
Signed-off-by: The one with the braid <the-one@with-the-braid.cf>
This commit is contained in:
commit
cf9609d699
20 changed files with 1483 additions and 0 deletions
325
lib/src/models/pass.dart
Normal file
325
lib/src/models/pass.dart
Normal file
|
@ -0,0 +1,325 @@
|
|||
class PassMetadata {
|
||||
final String? description;
|
||||
final int formatVersion;
|
||||
final String? organizationName;
|
||||
final String? passTypeIdentifier;
|
||||
final String? serialNumber;
|
||||
final String? teamIdentifier;
|
||||
final bool? suppressStripShine;
|
||||
final EventTicket? eventTicket;
|
||||
final Barcode? barcode;
|
||||
final String? foregroundColor;
|
||||
final List<Location>? locations;
|
||||
|
||||
const PassMetadata({
|
||||
required this.description,
|
||||
required this.formatVersion,
|
||||
required this.organizationName,
|
||||
required this.passTypeIdentifier,
|
||||
required this.serialNumber,
|
||||
required this.teamIdentifier,
|
||||
required this.suppressStripShine,
|
||||
required this.eventTicket,
|
||||
required this.barcode,
|
||||
required this.foregroundColor,
|
||||
required this.locations,
|
||||
});
|
||||
|
||||
factory PassMetadata.fromJson(Map<String, Object?> json) => PassMetadata(
|
||||
description: json['description'] as String?,
|
||||
formatVersion: json['formatVersion'] as int,
|
||||
organizationName: json['organizationName'] as String?,
|
||||
passTypeIdentifier: json['passTypeIdentifier'] as String?,
|
||||
serialNumber: json['serialNumber'] as String?,
|
||||
teamIdentifier: json['teamIdentifier'] as String?,
|
||||
suppressStripShine: json['suppressStripShine'] as bool?,
|
||||
eventTicket: json['ventTicket'] == null
|
||||
? null
|
||||
: EventTicket.fromJson(
|
||||
json['eventTicket'] as Map<String, Object?>? ?? {},
|
||||
),
|
||||
barcode: json['barcode'] == null
|
||||
? null
|
||||
: Barcode.fromJson(json['barcode'] as Map<String, Object?>? ?? {}),
|
||||
foregroundColor: json['foregroundColor'] as String?,
|
||||
locations: (json['locations'] as List)
|
||||
.map((i) => Location.fromJson(i))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'description': description,
|
||||
'formatVersion': formatVersion,
|
||||
'organizationName': organizationName,
|
||||
'passTypeIdentifier': passTypeIdentifier,
|
||||
'serialNumber': serialNumber,
|
||||
'teamIdentifier': teamIdentifier,
|
||||
'suppressStripShine': suppressStripShine,
|
||||
'eventTicket': eventTicket?.toJson(),
|
||||
'barcode': barcode?.toJson(),
|
||||
'foregroundColor': foregroundColor,
|
||||
'locations': locations?.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
class EventTicket {
|
||||
final List<HeaderField> headerFields;
|
||||
final List<PrimaryField> primaryFields;
|
||||
final List<SecondaryField> secondaryFields;
|
||||
final List<BackField> backFields;
|
||||
final List<AuxiliaryField> auxiliaryFields;
|
||||
|
||||
const EventTicket({
|
||||
required this.headerFields,
|
||||
required this.primaryFields,
|
||||
required this.secondaryFields,
|
||||
required this.backFields,
|
||||
required this.auxiliaryFields,
|
||||
});
|
||||
|
||||
factory EventTicket.fromJson(Map<String, Object?> json) => EventTicket(
|
||||
headerFields: (json['headerFields'] as List)
|
||||
.map((i) => HeaderField.fromJson(i))
|
||||
.toList(),
|
||||
primaryFields: (json['primaryFields'] as List)
|
||||
.map((i) => PrimaryField.fromJson(i))
|
||||
.toList(),
|
||||
secondaryFields: (json['secondaryFields'] as List)
|
||||
.map((i) => SecondaryField.fromJson(i))
|
||||
.toList(),
|
||||
backFields: (json['backFields'] as List)
|
||||
.map((i) => BackField.fromJson(i))
|
||||
.toList(),
|
||||
auxiliaryFields: (json['auxiliaryFields'] as List)
|
||||
.map((i) => AuxiliaryField.fromJson(i))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'headerFields': headerFields.map((i) => i.toJson()).toList(),
|
||||
'primaryFields': primaryFields.map((i) => i.toJson()).toList(),
|
||||
'secondaryFields': secondaryFields.map((i) => i.toJson()).toList(),
|
||||
'backFields': backFields.map((i) => i.toJson()).toList(),
|
||||
'auxiliaryFields': auxiliaryFields.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
class HeaderField {
|
||||
final String? key;
|
||||
final String? value;
|
||||
final String? label;
|
||||
final String? changeMessage;
|
||||
final String? textAlignment;
|
||||
|
||||
const HeaderField({
|
||||
required this.key,
|
||||
required this.value,
|
||||
required this.label,
|
||||
required this.changeMessage,
|
||||
required this.textAlignment,
|
||||
});
|
||||
|
||||
factory HeaderField.fromJson(Map<String, Object?> json) => HeaderField(
|
||||
key: json['key'] as String?,
|
||||
value: json['value'] as String?,
|
||||
label: json['label'] as String?,
|
||||
changeMessage: json['changeMessage'] as String?,
|
||||
textAlignment: json['textAlignment'] as String?,
|
||||
);
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'key': key,
|
||||
'value': value,
|
||||
'label': label,
|
||||
'changeMessage': changeMessage,
|
||||
'textAlignment': textAlignment,
|
||||
};
|
||||
}
|
||||
|
||||
class PrimaryField {
|
||||
final String? key;
|
||||
final String? value;
|
||||
final String? label;
|
||||
final String? changeMessage;
|
||||
final String? textAlignment;
|
||||
|
||||
const PrimaryField({
|
||||
required this.key,
|
||||
required this.value,
|
||||
required this.label,
|
||||
required this.changeMessage,
|
||||
required this.textAlignment,
|
||||
});
|
||||
|
||||
factory PrimaryField.fromJson(Map<String, Object?> json) => PrimaryField(
|
||||
key: json['key'] as String?,
|
||||
value: json['value'] as String?,
|
||||
label: json['label'] as String?,
|
||||
changeMessage: json['changeMessage'] as String?,
|
||||
textAlignment: json['textAlignment'] as String?,
|
||||
);
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'key': key,
|
||||
'value': value,
|
||||
'label': label,
|
||||
'changeMessage': changeMessage,
|
||||
'textAlignment': textAlignment,
|
||||
};
|
||||
}
|
||||
|
||||
class SecondaryField {
|
||||
final String? key;
|
||||
final String? value;
|
||||
final String? label;
|
||||
final String? changeMessage;
|
||||
final String? textAlignment;
|
||||
|
||||
const SecondaryField({
|
||||
required this.key,
|
||||
required this.value,
|
||||
required this.label,
|
||||
required this.changeMessage,
|
||||
required this.textAlignment,
|
||||
});
|
||||
|
||||
factory SecondaryField.fromJson(Map<String, Object?> json) => SecondaryField(
|
||||
key: json['key'] as String?,
|
||||
value: json['value'] as String?,
|
||||
label: json['label'] as String?,
|
||||
changeMessage: json['changeMessage'] as String?,
|
||||
textAlignment: json['textAlignment'] as String?,
|
||||
);
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'key': key,
|
||||
'value': value,
|
||||
'label': label,
|
||||
'changeMessage': changeMessage,
|
||||
'textAlignment': textAlignment,
|
||||
};
|
||||
}
|
||||
|
||||
class BackField {
|
||||
final String? key;
|
||||
final String? value;
|
||||
final String? label;
|
||||
final String? changeMessage;
|
||||
final String? textAlignment;
|
||||
|
||||
const BackField({
|
||||
required this.key,
|
||||
required this.value,
|
||||
required this.label,
|
||||
required this.changeMessage,
|
||||
required this.textAlignment,
|
||||
});
|
||||
|
||||
factory BackField.fromJson(Map<String, Object?> json) => BackField(
|
||||
key: json['key'] as String?,
|
||||
value: json['value'] as String?,
|
||||
label: json['label'] as String?,
|
||||
changeMessage: json['changeMessage'] as String?,
|
||||
textAlignment: json['textAlignment'] as String?,
|
||||
);
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'key': key,
|
||||
'value': value,
|
||||
'label': label,
|
||||
'changeMessage': changeMessage,
|
||||
'textAlignment': textAlignment,
|
||||
};
|
||||
}
|
||||
|
||||
class AuxiliaryField {
|
||||
final String? key;
|
||||
final String? value;
|
||||
final String? label;
|
||||
final String? changeMessage;
|
||||
final String? textAlignment;
|
||||
|
||||
const AuxiliaryField({
|
||||
required this.key,
|
||||
required this.value,
|
||||
required this.label,
|
||||
required this.changeMessage,
|
||||
required this.textAlignment,
|
||||
});
|
||||
|
||||
factory AuxiliaryField.fromJson(Map<String, Object?> json) => AuxiliaryField(
|
||||
key: json['key'] as String?,
|
||||
value: json['value'] as String?,
|
||||
label: json['label'] as String?,
|
||||
changeMessage: json['changeMessage'] as String?,
|
||||
textAlignment: json['textAlignment'] as String?,
|
||||
);
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'key': key,
|
||||
'value': value,
|
||||
'label': label,
|
||||
'changeMessage': changeMessage,
|
||||
'textAlignment': textAlignment,
|
||||
};
|
||||
}
|
||||
|
||||
class Barcode {
|
||||
final String? format;
|
||||
final String? message;
|
||||
final String? messageEncoding;
|
||||
final String? altText;
|
||||
|
||||
const Barcode({
|
||||
required this.format,
|
||||
required this.message,
|
||||
required this.messageEncoding,
|
||||
required this.altText,
|
||||
});
|
||||
|
||||
factory Barcode.fromJson(Map<String, Object?> json) => Barcode(
|
||||
format: json['format'] as String?,
|
||||
message: json['message'] as String?,
|
||||
messageEncoding: json['messageEncoding'] as String?,
|
||||
altText: json['altText'] as String?,
|
||||
);
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'format': format,
|
||||
'message': message,
|
||||
'messageEncoding': messageEncoding,
|
||||
'altText': altText,
|
||||
};
|
||||
}
|
||||
|
||||
class Location {
|
||||
final double? latitude;
|
||||
final double? longitude;
|
||||
final double? altitude;
|
||||
final double? distance;
|
||||
final String? relevantText;
|
||||
|
||||
const Location({
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.altitude,
|
||||
required this.distance,
|
||||
required this.relevantText,
|
||||
});
|
||||
|
||||
factory Location.fromJson(Map<String, Object?> json) => Location(
|
||||
latitude: json['latitude'] as double?,
|
||||
longitude: json['longitude'] as double?,
|
||||
altitude: json['altitude'] as double?,
|
||||
distance: json['distance'] as double?,
|
||||
relevantText: json['relevantText'] as String?,
|
||||
);
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'altitude': altitude,
|
||||
'distance': distance,
|
||||
'relevantText': relevantText,
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue