Solian/lib/services.dart

33 lines
910 B
Dart
Raw Normal View History

import 'package:get/get.dart';
2024-05-18 10:17:16 +00:00
abstract class ServiceFinder {
2024-08-01 15:44:07 +00:00
static const bool devFlag = false;
2024-05-18 10:17:16 +00:00
static const String dealerUrl =
devFlag ? 'http://localhost:8442' : 'https://api.sn.solsynth.dev';
2024-08-13 02:54:42 +00:00
static const String capitalUrl =
devFlag ? 'http://localhost:8444' : 'https://solsynth.dev';
static String buildUrl(String serviceName, String? append) {
append ??= '';
if (serviceName == 'dealer') {
return '$dealerUrl$append';
2024-08-13 02:54:42 +00:00
} else if (serviceName == 'capital') {
return '$capitalUrl$append';
}
2024-07-26 17:39:20 +00:00
return '$dealerUrl/cgi/$serviceName$append';
}
static GetConnect configureClient(String serviceName,
{timeout = const Duration(seconds: 5)}) {
2024-06-08 13:35:50 +00:00
final client = GetConnect(
timeout: timeout,
userAgent: 'Solian/1.1',
sendUserAgent: true,
2024-06-08 13:35:50 +00:00
);
client.httpClient.baseUrl = buildUrl(serviceName, null);
return client;
}
2024-05-25 16:11:00 +00:00
}