63 lines
1.3 KiB
Dart
63 lines
1.3 KiB
Dart
|
|
import 'accountData.dart';
|
|
|
|
enum EndpointMode {
|
|
live,
|
|
stage,
|
|
}
|
|
|
|
class EndpointOptions {
|
|
Endpoint live;
|
|
Endpoint? staged;
|
|
EndpointOptions({required this.live, required this.staged});
|
|
|
|
Endpoint get(EndpointMode mode) {
|
|
if(staged == null || mode == EndpointMode.live) return live;
|
|
return staged!;
|
|
}
|
|
}
|
|
|
|
class Endpoint {
|
|
String domain;
|
|
String path;
|
|
|
|
Endpoint({required this.domain, this.path = ''});
|
|
|
|
String full() => domain + path;
|
|
}
|
|
|
|
class EndpointData {
|
|
static final EndpointData _instance = EndpointData._construct();
|
|
|
|
factory EndpointData() => _instance;
|
|
|
|
EndpointData._construct();
|
|
|
|
EndpointMode getEndpointMode() {
|
|
late String existingName;
|
|
existingName = AccountData().getUsername();
|
|
return existingName.startsWith('google') ? EndpointMode.stage : EndpointMode.live;
|
|
}
|
|
|
|
Endpoint webuntis() => EndpointOptions(
|
|
live: Endpoint(
|
|
domain: 'peleus.webuntis.com',
|
|
),
|
|
staged: Endpoint(
|
|
domain: 'mhsl.eu',
|
|
path: '/marianum/marianummobile/webuntis/public/index.php/api'
|
|
),
|
|
).get(getEndpointMode());
|
|
|
|
Endpoint nextcloud() => EndpointOptions(
|
|
live: Endpoint(
|
|
domain: 'cloud.marianum-fulda.de',
|
|
),
|
|
staged: Endpoint(
|
|
domain: 'mhsl.eu',
|
|
path: '/marianum/marianummobile/cloud',
|
|
)
|
|
).get(getEndpointMode());
|
|
|
|
}
|