getShare method

Future<List<SharingDetail>> getShare([
  1. String? nodeId
])

Obtains who a node is shared with.

Optionally takes the id of the node and returns who it's shared with.

Implementation

Future<List<SharingDetail>> getShare([String? nodeId]) async {
  final uri = _urlBase.getPath(_nodeSharing, {
    'node_id': nodeId ?? '',
  });

  final resp = await get(
    uri,
    headers: {
      URLBase.authHeader: accessToken,
    },
  );
  final dynamic bodyResp = await JsonIsolate().decodeJson(resp.body);
  if (resp.statusCode != 200) {
    if (bodyResp is Map) {
      throw bodyResp['description'];
    }
    throw 'Bad state!';
  }

  return bodyResp['node_sharing']
      ?.map<SharingDetail>((e) => SharingDetail.fromJson(e))
      ?.toList();
}