Line data Source code
1 : import 'package:fast_immutable_collections/fast_immutable_collections.dart';
2 : import 'package:freezed_annotation/freezed_annotation.dart';
3 : import 'package:redfire/types.dart';
4 :
5 : part 'organisation_model.freezed.dart';
6 : part 'organisation_model.g.dart';
7 :
8 : @freezed
9 : class OrganisationModel with _$OrganisationModel, ReduxState {
10 : static const String className = 'OrganisationModel';
11 :
12 0 : const OrganisationModel._();
13 : factory OrganisationModel({
14 : // A unique id, current implementation is the firestore document id
15 : required String id,
16 : required String name,
17 : required ISet<String> ownerIds,
18 : required ISet<String> adminIds,
19 : required ISet<String> memberIds,
20 : }) = _Organisation;
21 :
22 0 : factory OrganisationModel.fromJson(JsonMap json) =>
23 0 : _$OrganisationModelFromJson(json);
24 :
25 0 : factory OrganisationModel.init({required String name}) => OrganisationModel(
26 : id: '', // temporary value indicating not saved to DB yet
27 : name: name,
28 0 : ownerIds: ISet(),
29 0 : adminIds: ISet(),
30 0 : memberIds: ISet(),
31 : );
32 :
33 0 : @override
34 : String get typeName => className;
35 : }
|