2021-08-20 13:26:00 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
import 'package:cake_wallet/yat/yat_exception.dart';
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
|
|
|
|
Future<String> fetchYatAddress(String emojiId) async {
|
2021-08-27 17:46:24 +00:00
|
|
|
const _requestURL = 'https://a.y.at/emoji_id/';
|
2021-08-20 13:26:00 +00:00
|
|
|
|
|
|
|
final url = _requestURL + emojiId;
|
2021-08-27 17:46:24 +00:00
|
|
|
final response = await get(url);
|
2021-08-20 13:26:00 +00:00
|
|
|
|
|
|
|
if (response.statusCode != 200) {
|
|
|
|
throw YatException(text: response.body.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
2021-08-27 17:46:24 +00:00
|
|
|
final yatAddress = responseJSON['result'][2]['data'] as String;
|
2021-08-20 13:26:00 +00:00
|
|
|
return yatAddress;
|
|
|
|
}
|