Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
delivery_voucher_document.dart
Go to the documentation of this file.
1import 'dart:convert';
2
4 final DateTime? collectionDate;
5 final List<CollectionVoucher>? collectionVoucher;
8 final Partner? driver;
9 final int? id;
12 final DateTime? unloadingDate;
14
16 this.collectionDate,
17 this.collectionVoucher,
18 this.containerNumber,
19 this.containerType,
20 this.driver,
21 this.id,
22 this.productName,
23 this.reference,
24 this.unloadingDate,
25 this.vehiclePlate,
26 });
27
28 factory DeliveryVoucherDocument.fromJson(Map<String, dynamic> json) {
30 collectionDate: json['collectionDate'] != null
31 ? DateTime.tryParse(json['collectionDate'])
32 : null,
33 collectionVoucher: json['collectionVoucher'] != null
34 ? (json['collectionVoucher'] as List)
35 .map((v) => CollectionVoucher.fromJson(v))
36 .toList()
37 : null,
38 containerNumber: json['containerNumber'],
39 containerType: json['containerType'],
40 driver: json['driver'] != null ? Partner.fromJson(json['driver']) : null,
41 id: json['id'],
42 productName: json['productName'] != null
43 ? LocalizedString.fromJsonString(json['productName'])
44 : null,
45 reference: json['reference'],
46 unloadingDate: json['unloadingDate'] != null
47 ? DateTime.tryParse(json['unloadingDate'])
48 : null,
49 vehiclePlate: json['vehiclePlate'],
50 );
51 }
52
53 Map<String, dynamic> toJson() {
54 final data = <String, dynamic>{};
55 if (collectionDate != null) {
56 data['collectionDate'] = collectionDate!.toIso8601String();
57 }
58 if (collectionVoucher != null) {
59 data['collectionVoucher'] =
60 collectionVoucher!.map((e) => e.toJson()).toList();
61 }
62 data['containerNumber'] = containerNumber;
63 data['containerType'] = containerType;
64 if (driver != null) {
65 data['driver'] = driver!.toJson();
66 }
67 data['id'] = id;
68 if (productName != null) {
69 data['productName'] = json.encode(productName!.values);
70 }
71 data['reference'] = reference;
72 if (unloadingDate != null) {
73 data['unloadingDate'] = unloadingDate!.toIso8601String();
74 }
75 data['vehiclePlate'] = vehiclePlate;
76 return data;
77 }
78}
79
81 final int? id;
82 final String? name;
87
89 this.id,
90 this.name,
91 this.address,
92 this.collectionPoint,
93 this.contactPerson,
94 this.generatorId,
95 });
96
97 factory CollectionVoucher.fromJson(Map<String, dynamic> json) {
98 return CollectionVoucher(
99 id: json['id'],
100 name: json['name'],
101 address: json['address'],
102 collectionPoint: json['collectionPoint'],
103 contactPerson: json['contactPerson'],
104 generatorId: json['generatorId'],
105 );
106 }
107
108 Map<String, dynamic> toJson() => {
109 'id': id,
110 'name': name,
111 'address': address,
112 'collectionPoint': collectionPoint,
113 'contactPerson': contactPerson,
114 'generatorId': generatorId,
115 };
116}
117
118class Partner {
119 final int? id;
120 final bool? isCompany;
121 final String? name;
122 final int? parentId;
123 final String? partnerLatitude;
125 final String? street;
126
128 this.id,
129 this.isCompany,
130 this.name,
131 this.parentId,
132 this.partnerLatitude,
133 this.partnerLongitude,
134 this.street,
135 });
136
137 factory Partner.fromJson(Map<String, dynamic> json) {
138 return Partner(
139 id: json['id'],
140 isCompany: json['isCompany'],
141 name: json['name'],
142 parentId: json['parentId'],
143 partnerLatitude: json['partnerLatitude'],
144 partnerLongitude: json['partnerLongitude'],
145 street: json['street'],
146 );
147 }
148
149 Map<String, dynamic> toJson() => {
150 'id': id,
151 'isCompany': isCompany,
152 'name': name,
153 'parentId': parentId,
154 'partnerLatitude': partnerLatitude,
155 'partnerLongitude': partnerLongitude,
156 'street': street,
157 };
158}
159
160class LocalizedString {
161 final Map<String, String> values;
162
163 LocalizedString(this.values);
164
165 factory LocalizedString.fromJsonString(String jsonStr) {
166 try {
167 final Map<String, dynamic> decoded =
168 json.decode(jsonStr) as Map<String, dynamic>;
169 return LocalizedString(decoded.map((k, v) => MapEntry(k, v.toString())));
170 } catch (e) {
171 return LocalizedString({'en_US': jsonStr}); // fallback
172 }
173 }
174
175 String? get(String locale) => values[locale];
176
177 String? get defaultValue => values['en_US'] ?? values.values.firstOrNull;
178}
DeliveryVoucherDocument({ this.collectionDate, this.collectionVoucher, this.containerNumber, this.containerType, this.driver, this.id, this.productName, this.reference, this.unloadingDate, this.vehiclePlate, })
final List< CollectionVoucher > collectionVoucher
Partner({ this.id, this.isCompany, this.name, this.parentId, this.partnerLatitude, this.partnerLongitude, this.street, })
factory Partner fromJson(Map< String, dynamic > json)
Partner({ required this.contactName, required this.id, required this.isCompany, required this.name, required this.parentId, required this.partnerLatitude, required this.partnerLongitude, required this.street, })
Map< String, dynamic > toJson()
Map< String, dynamic > toJson()
CollectionVoucher({ this.id, this.name, this.address, this.collectionPoint, this.contactPerson, this.generatorId, })
class Partner String
final String contactPerson
class Partner values
String get defaultValue
final String generatorId
final String collectionPoint
String get(String locale)
final String address
LocalizedString(this.values)
class Partner String