Solian/lib/services.dart
2024-07-27 01:39:20 +08:00

33 lines
916 B
Dart

import 'package:get/get.dart';
abstract class ServiceFinder {
static const bool devFlag = false;
static const String dealerUrl =
devFlag ? 'http://localhost:8442' : 'https://api.sn.solsynth.dev';
static const String passportUrl =
devFlag ? 'http://localhost:8444' : 'https://id.solsynth.dev';
static String buildUrl(String serviceName, String? append) {
append ??= '';
if (serviceName == 'dealer') {
return '$dealerUrl$append';
} else if (serviceName == 'passport') {
return '$passportUrl$append';
}
return '$dealerUrl/cgi/$serviceName$append';
}
static GetConnect configureClient(String serviceName,
{timeout = const Duration(seconds: 5)}) {
final client = GetConnect(
timeout: timeout,
userAgent: 'Solian/1.1',
sendUserAgent: true,
);
client.httpClient.baseUrl = buildUrl(serviceName, null);
return client;
}
}