cashumit/lib/models/firefly_account.dart

31 lines
860 B
Dart

// lib/models/firefly_account.dart
/// Represents an account retrieved from the Firefly III API.
class FireflyAccount {
final String id;
final String name;
final String type;
// Tambahkan field lain jika diperlukan, seperti currency, balance, dll.
FireflyAccount({
required this.id,
required this.name,
required this.type,
});
/// Creates a FireflyAccount instance from a JSON object.
factory FireflyAccount.fromJson(Map<String, dynamic> json) {
final attributes = json['attributes'] as Map<String, dynamic>;
return FireflyAccount(
id: json['id'].toString(), // ID bisa string atau int, pastikan konsisten
name: attributes['name'] as String,
type: attributes['type'] as String,
);
}
@override
String toString() {
// Digunakan untuk menampilkan nama akun di dropdown
return name;
}
}