add sat endpoint

This commit is contained in:
sneurlax 2023-07-19 10:41:23 -05:00
parent 51155372d3
commit 828782f00c
2 changed files with 24 additions and 18 deletions

View file

@ -29,18 +29,18 @@ class SatResponse {
factory SatResponse.fromJson(Map<String, dynamic> json) { factory SatResponse.fromJson(Map<String, dynamic> json) {
return SatResponse( return SatResponse(
links: SatLinks.fromJson(json['_links']), links: SatLinks.fromJson(json['_links'] as Map<String, dynamic>),
block: json['block'], block: json['block'] as int,
cycle: json['cycle'], cycle: json['cycle'] as int,
decimal: json['decimal'], decimal: json['decimal'] as String,
degree: json['degree'], degree: json['degree'] as String,
epoch: json['epoch'], epoch: json['epoch'] as int,
name: json['name'], name: json['name'] as String,
offset: json['offset'], offset: json['offset'] as int,
percentile: json['percentile'], percentile: json['percentile'] as String,
period: json['period'], period: json['period'] as int,
rarity: json['rarity'], rarity: json['rarity'] as String,
timestamp: json['timestamp'], timestamp: json['timestamp'] as String,
); );
} }
} }
@ -62,11 +62,11 @@ class SatLinks {
factory SatLinks.fromJson(Map<String, dynamic> json) { factory SatLinks.fromJson(Map<String, dynamic> json) {
return SatLinks( return SatLinks(
block: SatLink.fromJson(json['block']), block: SatLink.fromJson(json['block'] as Map<String, dynamic>),
inscription: SatLink.fromJson(json['inscription']), inscription: SatLink.fromJson(json['inscription'] as Map<String, dynamic>),
next: SatLink.fromJson(json['next']), next: SatLink.fromJson(json['next'] as Map<String, dynamic>),
prev: SatLink.fromJson(json['prev']), prev: SatLink.fromJson(json['prev'] as Map<String, dynamic>),
self: SatLink.fromJson(json['self']), self: SatLink.fromJson(json['self'] as Map<String, dynamic>),
); );
} }
} }
@ -77,6 +77,6 @@ class SatLink {
SatLink({required this.href}); SatLink({required this.href});
factory SatLink.fromJson(Map<String, dynamic> json) { factory SatLink.fromJson(Map<String, dynamic> json) {
return SatLink(href: json['href']); return SatLink(href: json['href'] as String);
} }
} }

View file

@ -3,6 +3,7 @@ import 'package:http/http.dart' as http;
import 'package:stackwallet/dto/ordinals/feed_response.dart'; import 'package:stackwallet/dto/ordinals/feed_response.dart';
import 'package:stackwallet/dto/ordinals/inscription_response.dart'; import 'package:stackwallet/dto/ordinals/inscription_response.dart';
import 'package:stackwallet/dto/ordinals/sat_response.dart';
class OrdinalsAPI { class OrdinalsAPI {
final String baseUrl; final String baseUrl;
@ -36,4 +37,9 @@ class OrdinalsAPI {
final response = await _getResponse('/inscription/$inscriptionId'); final response = await _getResponse('/inscription/$inscriptionId');
return InscriptionResponse.fromJson(response); return InscriptionResponse.fromJson(response);
} }
Future<SatResponse> getSatDetails(int satNumber) async {
final response = await _getResponse('/sat/$satNumber');
return SatResponse.fromJson(response);
}
} }