All checks were successful
update version / increment-build-number (push) Successful in 9s
70 lines
1.4 KiB
Dart
70 lines
1.4 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() {
|
|
return domain + path;
|
|
}
|
|
}
|
|
|
|
class EndpointData {
|
|
static final EndpointData _instance = EndpointData._construct();
|
|
|
|
factory EndpointData() {
|
|
return _instance;
|
|
}
|
|
|
|
EndpointData._construct();
|
|
|
|
EndpointMode getEndpointMode() {
|
|
late String existingName;
|
|
existingName = AccountData().getUsername();
|
|
return existingName.startsWith("google") ? EndpointMode.stage : EndpointMode.live;
|
|
}
|
|
|
|
Endpoint webuntis() {
|
|
return EndpointOptions(
|
|
live: Endpoint(
|
|
domain: "peleus.webuntis.com",
|
|
),
|
|
staged: Endpoint(
|
|
domain: "mhsl.eu",
|
|
path: "/marianum/marianummobile/webuntis/public/index.php/api"
|
|
),
|
|
).get(getEndpointMode());
|
|
}
|
|
|
|
Endpoint nextcloud() {
|
|
return EndpointOptions(
|
|
live: Endpoint(
|
|
domain: "cloud.marianum-fulda.de",
|
|
),
|
|
staged: Endpoint(
|
|
domain: "mhsl.eu",
|
|
path: "/marianum/marianummobile/cloud",
|
|
)
|
|
).get(getEndpointMode());
|
|
}
|
|
|
|
} |