create method

Create a group

Implementation

Future<GroupInfoEntity> create(
  Map<String, List<ImageTransformation>> files,
) async {
  assert(files.length <= 1000, 'Should be in 1..1000 range');

  final entries = files.entries.toList();
  final request =
      createMultipartRequest('POST', buildUri('$uploadUrl/group/'))
        ..fields.addAll({'pub_key': publicKey})
        ..fields.addEntries(List.generate(files.length, (index) {
          final entry = entries[index];
          final pathTransformer =
              PathTransformer(entry.key, transformations: entry.value);
          return MapEntry(
              'files[$index]',
              pathTransformer.hasTransformations
                  ? pathTransformer.path
                  : pathTransformer.id);
        }));

  return GroupInfoEntity.fromJson(
      await resolveStreamedResponse(request.send()));
}