import 'dart:convert'; import 'package:get/get.dart'; import 'package:star_lock/network/api_provider.dart'; import 'package:star_lock/network/api_provider_base.dart'; import 'package:star_lock/talk/startChart/entity/relay_info_entity.dart'; import 'package:star_lock/talk/startChart/entity/report_information_data.dart'; import 'package:star_lock/talk/startChart/entity/star_chart_register_node_entity.dart'; class StartChartApi extends BaseProvider { // 星图url final String _startChartHost = 'http://sls1-scd.star-lock.cn:8080'; static StartChartApi get to => Get.put(StartChartApi()); // 星图--注册节点 Future starChartRegisterNode({ required String product, required String model, required String name, required String unique, }) async { final response = await post( _startChartHost + starChartRegisterNodeURL.toUrl, jsonEncode({ 'product': product, 'model': model, 'name': name, 'unique': unique, }), isUnShowLoading: true, isUserBaseUrl: false, ); return StarChartRegisterNodeEntity.fromJson(response.body); } // 星图--中继查询 Future relayQueryInfo() async { final response = await get( _startChartHost + relayQueryInfoURL.toUrl, isUnShowLoading: true, isUserBaseUrl: false, ); return RelayInfoEntity.fromJson(response.body); } // 星图--上报信息至发现服务 Future reportInformation({ required ReportInformationData reportInformationData, }) async { final response = await post( _startChartHost + reportInformationDataURL.toUrl, jsonEncode(reportInformationData.toJson()), isUnShowLoading: true, isUserBaseUrl: false, ); return response; } // 星图--解析对端信息 Future analyzeInformationOtherEnd({ required String peerId, }) async { final response = await get( _startChartHost + analyzeInformationOtherEndURL.toUrl + '?id=$peerId', isUnShowLoading: true, isUserBaseUrl: false, ); return response; } }