getGroup method

Future<DeviceGroups> getGroup([
  1. String? groupId
])

Obtains details about user groups.

Gets all groups if the groupId is not provided.

Implementation

Future<DeviceGroups> getGroup([String? groupId]) async {
  final uri = _urlBase.getPath(_devGroupBase, {
    'group_id': groupId ?? '',
  });

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

  return DeviceGroups.fromJson(bodyResp);
}