apiGroup method

ApiGroupDeclaration apiGroup(
  1. String name, {
  2. required String baseUrl,
  3. Map<String, String>? headers,
  4. List<Endpoint>? endpoints,
})

Declares an API group and attaches the supplied endpoints to it.

Implementation

ApiGroupDeclaration apiGroup(
  String name, {
  required String baseUrl,
  Map<String, String>? headers,
  List<Endpoint>? endpoints,
}) {
  _ensureUnique(_apiGroupNames, name, 'api group');
  for (final endpoint in endpoints ?? const <Endpoint>[]) {
    endpoint.attachToGroup(name);
  }
  final declaration = ApiGroupDeclaration(
    name: name,
    baseUrl: baseUrl,
    headers: headers,
    endpoints: endpoints,
  );
  _apiGroups.add(declaration);
  return declaration;
}