structs for getAttachment

This commit is contained in:
Juan Marulanda De Los Rios 2025-02-18 16:38:22 -05:00
parent 7423135fea
commit fb9f7135dd

View File

@ -1,5 +1,7 @@
//data structures
import 'dart:typed_data';
class GetThreadResponse {
final int id;
final List<String> 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<AttachmentInfo> {
final List<AttachmentInfo> _attachments;
AttachmentInfoList(this._attachments);
factory AttachmentInfoList.fromJsonList(List<Map<String, dynamic>> jsonList) {
return AttachmentInfoList(jsonList.map((json) => AttachmentInfo.fromJson(json)).toList());
}
@override
Iterator<AttachmentInfo> 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<String, dynamic> json) {
return AttachmentResponse(name: json["name"], data: json["data"],);
}
}