diff --git a/lib/dto/ordinals/address_response.dart b/lib/dto/ordinals/address_response.dart new file mode 100644 index 000000000..024543b92 --- /dev/null +++ b/lib/dto/ordinals/address_response.dart @@ -0,0 +1,48 @@ +class AddressResponse { + final AddressLinks links; + final String address; + final List inscriptions; + + AddressResponse({ + required this.links, + required this.address, + required this.inscriptions, + }); + + factory AddressResponse.fromJson(Map json) { + final inscriptionsJson = json['inscriptions'] as List; + final inscriptions = inscriptionsJson + .map((inscriptionJson) => InscriptionLink.fromJson(inscriptionJson)) + .toList(); + + return AddressResponse( + links: AddressLinks.fromJson(json['_links']), + address: json['address'], + inscriptions: inscriptions, + ); + } +} + +class AddressLinks { + final AddressLink? self; + + AddressLinks({ + this.self, + }); + + factory AddressLinks.fromJson(Map json) { + return AddressLinks( + self: AddressLink.fromJson(json['self']), + ); + } +} + +class AddressLink { + final String href; + + AddressLink({required this.href}); + + factory AddressLink.fromJson(Map json) { + return AddressLink(href: json['href']); + } +} diff --git a/lib/dto/ordinals/block_response.dart b/lib/dto/ordinals/block_response.dart new file mode 100644 index 000000000..365098594 --- /dev/null +++ b/lib/dto/ordinals/block_response.dart @@ -0,0 +1,58 @@ +class BlockResponse { + final BlockLinks links; + final String hash; + final String previousBlockhash; + final int size; + final String target; + final String timestamp; + final int weight; + + BlockResponse({ + required this.links, + required this.hash, + required this.previousBlockhash, + required this.size, + required this.target, + required this.timestamp, + required this.weight, + }); + + factory BlockResponse.fromJson(Map json) { + return BlockResponse( + links: BlockLinks.fromJson(json['_links']), + hash: json['hash'], + previousBlockhash: json['previous_blockhash'], + size: json['size'], + target: json['target'], + timestamp: json['timestamp'], + weight: json['weight'], + ); + } +} + +class BlockLinks { + final BlockLink? prev; + final BlockLink? self; + + BlockLinks({ + this.prev, + this.self, + }); + + factory BlockLinks.fromJson(Map json) { + return BlockLinks( + prev: BlockLink.fromJson(json['prev']), + self: BlockLink.fromJson(json['self']), + ); + } +} + +class BlockLink { + final String href; + + BlockLink({required this.href}); + + factory BlockLink.fromJson(Map json) { + return BlockLink(href: json['href']); + } +} diff --git a/lib/dto/ordinals/content_response.dart b/lib/dto/ordinals/content_response.dart new file mode 100644 index 000000000..35a2c8ef8 --- /dev/null +++ b/lib/dto/ordinals/content_response.dart @@ -0,0 +1,19 @@ +class ContentResponse { + final FileLink fileLink; + + ContentResponse({required this.fileLink}); + + factory ContentResponse.fromJson(Map json) { + return ContentResponse(fileLink: FileLink.fromJson(json['_links']['file'])); + } +} + +class FileLink { + final String href; + + FileLink({required this.href}); + + factory FileLink.fromJson(Map json) { + return FileLink(href: json['href']); + } +} diff --git a/lib/dto/ordinals/feed_response.dart b/lib/dto/ordinals/feed_response.dart new file mode 100644 index 000000000..b6af1c1ca --- /dev/null +++ b/lib/dto/ordinals/feed_response.dart @@ -0,0 +1,14 @@ +class FeedResponse { + final List inscriptions; + + FeedResponse(this.inscriptions); + + factory FeedResponse.fromJson(Map json) { + final inscriptionsJson = json['_links']['inscriptions'] as List; + final inscriptions = inscriptionsJson + .map((inscriptionJson) => InscriptionLink.fromJson(inscriptionJson)) + .toList(); + + return FeedResponse(inscriptions); + } +} diff --git a/lib/dto/ordinals/inscription_response.dart b/lib/dto/ordinals/inscription_response.dart new file mode 100644 index 000000000..e06ddca6d --- /dev/null +++ b/lib/dto/ordinals/inscription_response.dart @@ -0,0 +1,95 @@ +class InscriptionResponse { + final InscriptionLinks links; + final String address; + final int contentLength; + final String contentType; + final int genesisFee; + final int genesisHeight; + final String genesisTransaction; + final String location; + final int number; + final int offset; + final String output; + final dynamic sat; // Change to appropriate type if available + final String timestamp; + + InscriptionResponse({ + required this.links, + required this.address, + required this.contentLength, + required this.contentType, + required this.genesisFee, + required this.genesisHeight, + required this.genesisTransaction, + required this.location, + required this.number, + required this.offset, + required this.output, + required this.sat, + required this.timestamp, + }); + + factory InscriptionResponse.fromJson(Map json) { + return InscriptionResponse( + links: InscriptionLinks.fromJson(json['_links']), + address: json['address'], + contentLength: json['content_length'], + contentType: json['content_type'], + genesisFee: json['genesis_fee'], + genesisHeight: json['genesis_height'], + genesisTransaction: json['genesis_transaction'], + location: json['location'], + number: json['number'], + offset: json['offset'], + output: json['output'], + sat: json['sat'], + timestamp: json['timestamp'], + ); + } +} + +class InscriptionLinks { + final InscriptionLink? content; + final InscriptionLink? genesisTransaction; + final InscriptionLink? next; + final InscriptionLink? output; + final InscriptionLink? prev; + final InscriptionLink? preview; + final InscriptionLink? sat; + final InscriptionLink? self; + + InscriptionLinks({ + this.content, + this.genesisTransaction, + this.next, + this.output, + this.prev, + this.preview, + this.sat, + this.self, + }); + + factory InscriptionLinks.fromJson(Map json) { + return InscriptionLinks( + content: InscriptionLink.fromJson(json['content']), + genesisTransaction: InscriptionLink.fromJson(json['genesis_transaction']), + next: InscriptionLink.fromJson(json['next']), + output: InscriptionLink.fromJson(json['output']), + prev: InscriptionLink.fromJson(json['prev']), + preview: InscriptionLink.fromJson(json['preview']), + sat: InscriptionLink.fromJson(json['sat']), + self: InscriptionLink.fromJson(json['self']), + ); + } +} + +class InscriptionLink { + final String href; + final String title; + + InscriptionLink({required this.href, required this.title}); + + factory InscriptionLink.fromJson(Map json) { + return InscriptionLink(href: json['href'], title: json['title']); + } +} diff --git a/lib/dto/ordinals/output_response b/lib/dto/ordinals/output_response new file mode 100644 index 000000000..cd25fe961 --- /dev/null +++ b/lib/dto/ordinals/output_response @@ -0,0 +1,42 @@ +class OutputResponse { + final OutputLinks links; + final String address; + final String scriptPubkey; + final String transaction; + final int value; + + OutputResponse({ + required this.links, + required this.address, + required this.scriptPubkey, + required this.transaction, + required this.value, + }); + + factory OutputResponse.fromJson(Map json) { + return OutputResponse( + links: OutputLinks.fromJson(json['_links']), + address: json['address'], + scriptPubkey: json['script_pubkey'], + transaction: json['transaction'], + value: json['value'], + ); + } +} + +class OutputLinks { + final OutputLink? self; + final TransactionLink? transaction; + + OutputLinks({ + this.self, + this.transaction, + }); + + factory OutputLinks.fromJson(Map json) { + return OutputLinks( + self: OutputLink.fromJson(json['self']), + transaction: TransactionLink.fromJson(json['transaction']), + ); + } +} \ No newline at end of file diff --git a/lib/dto/ordinals/preview_response.dart b/lib/dto/ordinals/preview_response.dart new file mode 100644 index 000000000..d7171702d --- /dev/null +++ b/lib/dto/ordinals/preview_response.dart @@ -0,0 +1,19 @@ +class PreviewResponse { + final ImageLink imageLink; + + PreviewResponse({required this.imageLink}); + + factory PreviewResponse.fromJson(Map json) { + return PreviewResponse(imageLink: ImageLink.fromJson(json['_links']['image'])); + } +} + +class ImageLink { + final String href; + + ImageLink({required this.href}); + + factory ImageLink.fromJson(Map json) { + return ImageLink(href: json['href']); + } +} \ No newline at end of file diff --git a/lib/dto/ordinals/sat_response.dart b/lib/dto/ordinals/sat_response.dart new file mode 100644 index 000000000..0f88918f3 --- /dev/null +++ b/lib/dto/ordinals/sat_response.dart @@ -0,0 +1,82 @@ +class SatResponse { + final SatLinks links; + final int block; + final int cycle; + final String decimal; + final String degree; + final int epoch; + final String name; + final int offset; + final String percentile; + final int period; + final String rarity; + final String timestamp; + + SatResponse({ + required this.links, + required this.block, + required this.cycle, + required this.decimal, + required this.degree, + required this.epoch, + required this.name, + required this.offset, + required this.percentile, + required this.period, + required this.rarity, + required this.timestamp, + }); + + factory SatResponse.fromJson(Map json) { + return SatResponse( + links: SatLinks.fromJson(json['_links']), + block: json['block'], + cycle: json['cycle'], + decimal: json['decimal'], + degree: json['degree'], + epoch: json['epoch'], + name: json['name'], + offset: json['offset'], + percentile: json['percentile'], + period: json['period'], + rarity: json['rarity'], + timestamp: json['timestamp'], + ); + } +} + +class SatLinks { + final SatLink? block; + final SatLink? inscription; + final SatLink? next; + final SatLink? prev; + final SatLink? self; + + SatLinks({ + this.block, + this.inscription, + this.next, + this.prev, + this.self, + }); + + factory SatLinks.fromJson(Map json) { + return SatLinks( + block: SatLink.fromJson(json['block']), + inscription: SatLink.fromJson(json['inscription']), + next: SatLink.fromJson(json['next']), + prev: SatLink.fromJson(json['prev']), + self: SatLink.fromJson(json['self']), + ); + } +} + +class SatLink { + final String href; + + SatLink({required this.href}); + + factory SatLink.fromJson(Map json) { + return SatLink(href: json['href']); + } +} diff --git a/lib/dto/ordinals/transaction_response.dart b/lib/dto/ordinals/transaction_response.dart new file mode 100644 index 000000000..b030a1daa --- /dev/null +++ b/lib/dto/ordinals/transaction_response.dart @@ -0,0 +1,78 @@ +class TransactionResponse { + final TransactionLinks links; + final List inputs; + final InscriptionLink inscription; + final List outputs; + final TransactionLink self; + final String transaction; + + TransactionResponse({ + required this.links, + required this.inputs, + required this.inscription, + required this.outputs, + required this.self, + required this.transaction, + }); + + factory TransactionResponse.fromJson(Map json) { + final inputsJson = json['_links']['inputs'] as List; + final inputs = inputsJson + .map((inputJson) => OutputLink.fromJson(inputJson)) + .toList(); + + final outputsJson = json['_links']['outputs'] as List; + final outputs = outputsJson + .map((outputJson) => OutputLink.fromJson(outputJson)) + .toList(); + + return TransactionResponse( + links: TransactionLinks.fromJson(json['_links']), + inputs: inputs, + inscription: InscriptionLink.fromJson(json['_links']['inscription']), + outputs: outputs, + self: TransactionLink.fromJson(json['_links']['self']), + transaction: json['transaction'], + ); + } +} + +class TransactionLinks { + final TransactionLink? block; + final InscriptionLink? inscription; + final TransactionLink? self; + + TransactionLinks({ + this.block, + this.inscription, + this.self, + }); + + factory TransactionLinks.fromJson(Map json) { + return TransactionLinks( + block: TransactionLink.fromJson(json['block']), + inscription: InscriptionLink.fromJson(json['inscription']), + self: TransactionLink.fromJson(json['self']), + ); + } +} + +class TransactionLink { + final String href; + + TransactionLink({required this.href}); + + factory TransactionLink.fromJson(Map json) { + return TransactionLink(href: json['href']); + } +} + +class OutputLink { + final String href; + + OutputLink({required this.href}); + + factory OutputLink.fromJson(Map json) { + return OutputLink(href: json['href']); + } +}