record method

  1. @override
Future<ResourceRecord> record(
  1. String resourceKey,
  2. Object id
)
override

GET /{resource}/{id} — the only call that returns per-record permissions.

Implementation

@override
Future<ResourceRecord> record(String resourceKey, Object id) async {
  final resource = await _resource(resourceKey);

  final response = await _read('$prefix/$resourceKey/$id');

  final data = response['data'];
  if (data is! Map<String, dynamic>) {
    throw StateError('Record response for `$resourceKey/$id` has no data.');
  }

  final permissions = response['permissions'];
  final actions = response['actions'];

  return ResourceRecord.fromJson(
    data,
    resource.recordKey,
    permissions: permissions is Map<String, dynamic> ? permissions : null,
    actions: actions is List ? actions : null,
  );
}