25 lines
763 B
Dart
25 lines
763 B
Dart
import 'package:ac_web/Api/ApiClient.dart';
|
|
|
|
/// Base class for every service that maps onto one backend controller.
|
|
///
|
|
/// Adding support for a new controller means:
|
|
/// 1. create the dtos under `Api/Dtos`
|
|
/// 2. create a `<Name>Service extends ApiServiceBase` with `controllerRoute`
|
|
/// 3. expose it as a lazy getter on [AcApi]
|
|
abstract class ApiServiceBase {
|
|
const ApiServiceBase(this.client);
|
|
|
|
final ApiClient client;
|
|
|
|
/// Route of the controller without leading slash, e.g. `agents`.
|
|
String get controllerRoute;
|
|
|
|
/// Combines the controller route with an optional relative sub path.
|
|
String route([String? subPath]) {
|
|
if (subPath == null || subPath.isEmpty) {
|
|
return controllerRoute;
|
|
}
|
|
return '$controllerRoute/$subPath';
|
|
}
|
|
}
|