stack_wallet/lib/dto/ordinals/address_response.dart

51 lines
1.2 KiB
Dart
Raw Normal View History

import 'package:stackwallet/dto/ordinals/inscription_link.dart';
2023-07-19 15:48:54 +00:00
class AddressResponse {
final AddressLinks links;
final String address;
final List<InscriptionLink> inscriptions;
AddressResponse({
required this.links,
required this.address,
required this.inscriptions,
});
factory AddressResponse.fromJson(Map<String, dynamic> json) {
final inscriptionsJson = json['inscriptions'] as List;
final inscriptions = inscriptionsJson
2023-07-19 15:48:54 +00:00
.map((inscriptionJson) => InscriptionLink.fromJson(inscriptionJson as Map<String, dynamic>))
.toList();
return AddressResponse(
2023-07-19 15:48:54 +00:00
links: AddressLinks.fromJson(json['_links'] as Map<String, dynamic>),
address: json['address'] as String,
inscriptions: inscriptions,
);
}
}
class AddressLinks {
final AddressLink? self;
AddressLinks({
this.self,
});
factory AddressLinks.fromJson(Map<String, dynamic> json) {
return AddressLinks(
2023-07-19 15:48:54 +00:00
self: AddressLink.fromJson(json['self'] as Map<String, dynamic>),
);
}
}
class AddressLink {
final String href;
AddressLink({required this.href});
factory AddressLink.fromJson(Map<String, dynamic> json) {
2023-07-19 15:48:54 +00:00
return AddressLink(href: json['href'] as String);
}
}