diff --git a/lib/structs.dart b/lib/structs.dart index 6eb1c17..b55beb9 100644 --- a/lib/structs.dart +++ b/lib/structs.dart @@ -1,5 +1,7 @@ //data structures +import 'dart:typed_data'; + class GetThreadResponse { final int id; final List messages; @@ -76,7 +78,7 @@ class SerializableMessage { required this.subject, required this.date, required this.uid, - required this.list, + required this.list, //email list??? required this.id, required this.in_reply_to, }); @@ -118,3 +120,29 @@ class AttachmentInfo { ); } } + +class AttachmentInfoList extends Iterable { + final List _attachments; + + AttachmentInfoList(this._attachments); + + factory AttachmentInfoList.fromJsonList(List> jsonList) { + return AttachmentInfoList(jsonList.map((json) => AttachmentInfo.fromJson(json)).toList()); + } + + @override + Iterator get iterator => _attachments.iterator; + + @override + String toString() => _attachments.toString(); +} + +class AttachmentResponse { + final name; + final Uint8List data; + AttachmentResponse({required this.name, required this.data}); + + factory AttachmentResponse.fromJson(Map json) { + return AttachmentResponse(name: json["name"], data: json["data"],); + } +}