getDirectory method

Future<Response> getDirectory(
  1. String path, {
  2. Map<String, String> additionalHeaderFields = const <String, String>{},
})

Generates an authorized GET to the S3I-Directory.

The path should starts with a /. For more information see https://dir.s3i.vswf.dev/apidoc/#. If you need to add additional information to the header (e.g. ETag), use additionalHeaderFields.

Throws a FormatException if the path could not be parsed to a valid Uri. Throws a NetworkAuthenticationException if AuthenticationManager.getAccessToken throws an exception. If there is no internet connection available a SocketException is thrown.

Implementation

Future<Response> getDirectory(String path,
    {Map<String, String> additionalHeaderFields =
        const <String, String>{}}) async {
  String originalToken = '';
  try {
    final AccessToken token = await authManager.getAccessToken();
    originalToken = token.originalToken;
  } on Exception catch (e) {
    throw NetworkAuthenticationException(e);
  }
  final Map<String, String> headers = <String, String>{
    'Content-Type': 'application/json'
  }
    ..addAll(<String, String>{'Authorization': 'Bearer $originalToken'})
    ..addAll(additionalHeaderFields);
  return Client().get(Uri.parse(directoryUrl + path), headers: headers);
}