2024-06-06 12:49:18 +00:00
|
|
|
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
|
|
|
|
2024-07-16 11:46:53 +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';
|
2024-06-06 12:49:18 +00:00
|
|
|
|
2024-07-16 11:46:53 +00:00
|
|
|
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-16 11:46:53 +00:00
|
|
|
}
|
2024-07-26 17:39:20 +00:00
|
|
|
return '$dealerUrl/cgi/$serviceName$append';
|
2024-07-16 11:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GetConnect configureClient(String serviceName,
|
2024-06-06 12:49:18 +00:00
|
|
|
{timeout = const Duration(seconds: 5)}) {
|
2024-06-08 13:35:50 +00:00
|
|
|
final client = GetConnect(
|
|
|
|
timeout: timeout,
|
2024-06-29 09:35:18 +00:00
|
|
|
userAgent: 'Solian/1.1',
|
|
|
|
sendUserAgent: true,
|
2024-06-08 13:35:50 +00:00
|
|
|
);
|
2024-07-16 11:46:53 +00:00
|
|
|
client.httpClient.baseUrl = buildUrl(serviceName, null);
|
2024-06-06 12:49:18 +00:00
|
|
|
|
|
|
|
return client;
|
|
|
|
}
|
2024-05-25 16:11:00 +00:00
|
|
|
}
|