mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat: notifications (#17701)
* feat: notifications * UI works * chore: pr feedback * initial fetch and clear notification upon logging out * fix: merge --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
23717ce981
commit
1b5fc9c665
55 changed files with 3186 additions and 196 deletions
180
mobile/openapi/lib/model/notification_create_dto.dart
generated
Normal file
180
mobile/openapi/lib/model/notification_create_dto.dart
generated
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.18
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class NotificationCreateDto {
|
||||
/// Returns a new [NotificationCreateDto] instance.
|
||||
NotificationCreateDto({
|
||||
this.data,
|
||||
this.description,
|
||||
this.level,
|
||||
this.readAt,
|
||||
required this.title,
|
||||
this.type,
|
||||
required this.userId,
|
||||
});
|
||||
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
Object? data;
|
||||
|
||||
String? description;
|
||||
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
NotificationLevel? level;
|
||||
|
||||
DateTime? readAt;
|
||||
|
||||
String title;
|
||||
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
NotificationType? type;
|
||||
|
||||
String userId;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is NotificationCreateDto &&
|
||||
other.data == data &&
|
||||
other.description == description &&
|
||||
other.level == level &&
|
||||
other.readAt == readAt &&
|
||||
other.title == title &&
|
||||
other.type == type &&
|
||||
other.userId == userId;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(data == null ? 0 : data!.hashCode) +
|
||||
(description == null ? 0 : description!.hashCode) +
|
||||
(level == null ? 0 : level!.hashCode) +
|
||||
(readAt == null ? 0 : readAt!.hashCode) +
|
||||
(title.hashCode) +
|
||||
(type == null ? 0 : type!.hashCode) +
|
||||
(userId.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'NotificationCreateDto[data=$data, description=$description, level=$level, readAt=$readAt, title=$title, type=$type, userId=$userId]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
if (this.data != null) {
|
||||
json[r'data'] = this.data;
|
||||
} else {
|
||||
// json[r'data'] = null;
|
||||
}
|
||||
if (this.description != null) {
|
||||
json[r'description'] = this.description;
|
||||
} else {
|
||||
// json[r'description'] = null;
|
||||
}
|
||||
if (this.level != null) {
|
||||
json[r'level'] = this.level;
|
||||
} else {
|
||||
// json[r'level'] = null;
|
||||
}
|
||||
if (this.readAt != null) {
|
||||
json[r'readAt'] = this.readAt!.toUtc().toIso8601String();
|
||||
} else {
|
||||
// json[r'readAt'] = null;
|
||||
}
|
||||
json[r'title'] = this.title;
|
||||
if (this.type != null) {
|
||||
json[r'type'] = this.type;
|
||||
} else {
|
||||
// json[r'type'] = null;
|
||||
}
|
||||
json[r'userId'] = this.userId;
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [NotificationCreateDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static NotificationCreateDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "NotificationCreateDto");
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return NotificationCreateDto(
|
||||
data: mapValueOfType<Object>(json, r'data'),
|
||||
description: mapValueOfType<String>(json, r'description'),
|
||||
level: NotificationLevel.fromJson(json[r'level']),
|
||||
readAt: mapDateTime(json, r'readAt', r''),
|
||||
title: mapValueOfType<String>(json, r'title')!,
|
||||
type: NotificationType.fromJson(json[r'type']),
|
||||
userId: mapValueOfType<String>(json, r'userId')!,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<NotificationCreateDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <NotificationCreateDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = NotificationCreateDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, NotificationCreateDto> mapFromJson(dynamic json) {
|
||||
final map = <String, NotificationCreateDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = NotificationCreateDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of NotificationCreateDto-objects as value to a dart map
|
||||
static Map<String, List<NotificationCreateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<NotificationCreateDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = NotificationCreateDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'title',
|
||||
'userId',
|
||||
};
|
||||
}
|
||||
|
||||
101
mobile/openapi/lib/model/notification_delete_all_dto.dart
generated
Normal file
101
mobile/openapi/lib/model/notification_delete_all_dto.dart
generated
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.18
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class NotificationDeleteAllDto {
|
||||
/// Returns a new [NotificationDeleteAllDto] instance.
|
||||
NotificationDeleteAllDto({
|
||||
this.ids = const [],
|
||||
});
|
||||
|
||||
List<String> ids;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is NotificationDeleteAllDto &&
|
||||
_deepEquality.equals(other.ids, ids);
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(ids.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'NotificationDeleteAllDto[ids=$ids]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
json[r'ids'] = this.ids;
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [NotificationDeleteAllDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static NotificationDeleteAllDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "NotificationDeleteAllDto");
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return NotificationDeleteAllDto(
|
||||
ids: json[r'ids'] is Iterable
|
||||
? (json[r'ids'] as Iterable).cast<String>().toList(growable: false)
|
||||
: const [],
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<NotificationDeleteAllDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <NotificationDeleteAllDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = NotificationDeleteAllDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, NotificationDeleteAllDto> mapFromJson(dynamic json) {
|
||||
final map = <String, NotificationDeleteAllDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = NotificationDeleteAllDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of NotificationDeleteAllDto-objects as value to a dart map
|
||||
static Map<String, List<NotificationDeleteAllDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<NotificationDeleteAllDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = NotificationDeleteAllDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'ids',
|
||||
};
|
||||
}
|
||||
|
||||
182
mobile/openapi/lib/model/notification_dto.dart
generated
Normal file
182
mobile/openapi/lib/model/notification_dto.dart
generated
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.18
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class NotificationDto {
|
||||
/// Returns a new [NotificationDto] instance.
|
||||
NotificationDto({
|
||||
required this.createdAt,
|
||||
this.data,
|
||||
this.description,
|
||||
required this.id,
|
||||
required this.level,
|
||||
this.readAt,
|
||||
required this.title,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
DateTime createdAt;
|
||||
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
Object? data;
|
||||
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? description;
|
||||
|
||||
String id;
|
||||
|
||||
NotificationLevel level;
|
||||
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
DateTime? readAt;
|
||||
|
||||
String title;
|
||||
|
||||
NotificationType type;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is NotificationDto &&
|
||||
other.createdAt == createdAt &&
|
||||
other.data == data &&
|
||||
other.description == description &&
|
||||
other.id == id &&
|
||||
other.level == level &&
|
||||
other.readAt == readAt &&
|
||||
other.title == title &&
|
||||
other.type == type;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(createdAt.hashCode) +
|
||||
(data == null ? 0 : data!.hashCode) +
|
||||
(description == null ? 0 : description!.hashCode) +
|
||||
(id.hashCode) +
|
||||
(level.hashCode) +
|
||||
(readAt == null ? 0 : readAt!.hashCode) +
|
||||
(title.hashCode) +
|
||||
(type.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'NotificationDto[createdAt=$createdAt, data=$data, description=$description, id=$id, level=$level, readAt=$readAt, title=$title, type=$type]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
|
||||
if (this.data != null) {
|
||||
json[r'data'] = this.data;
|
||||
} else {
|
||||
// json[r'data'] = null;
|
||||
}
|
||||
if (this.description != null) {
|
||||
json[r'description'] = this.description;
|
||||
} else {
|
||||
// json[r'description'] = null;
|
||||
}
|
||||
json[r'id'] = this.id;
|
||||
json[r'level'] = this.level;
|
||||
if (this.readAt != null) {
|
||||
json[r'readAt'] = this.readAt!.toUtc().toIso8601String();
|
||||
} else {
|
||||
// json[r'readAt'] = null;
|
||||
}
|
||||
json[r'title'] = this.title;
|
||||
json[r'type'] = this.type;
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [NotificationDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static NotificationDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "NotificationDto");
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return NotificationDto(
|
||||
createdAt: mapDateTime(json, r'createdAt', r'')!,
|
||||
data: mapValueOfType<Object>(json, r'data'),
|
||||
description: mapValueOfType<String>(json, r'description'),
|
||||
id: mapValueOfType<String>(json, r'id')!,
|
||||
level: NotificationLevel.fromJson(json[r'level'])!,
|
||||
readAt: mapDateTime(json, r'readAt', r''),
|
||||
title: mapValueOfType<String>(json, r'title')!,
|
||||
type: NotificationType.fromJson(json[r'type'])!,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<NotificationDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <NotificationDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = NotificationDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, NotificationDto> mapFromJson(dynamic json) {
|
||||
final map = <String, NotificationDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = NotificationDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of NotificationDto-objects as value to a dart map
|
||||
static Map<String, List<NotificationDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<NotificationDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = NotificationDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'createdAt',
|
||||
'id',
|
||||
'level',
|
||||
'title',
|
||||
'type',
|
||||
};
|
||||
}
|
||||
|
||||
91
mobile/openapi/lib/model/notification_level.dart
generated
Normal file
91
mobile/openapi/lib/model/notification_level.dart
generated
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.18
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
class NotificationLevel {
|
||||
/// Instantiate a new enum with the provided [value].
|
||||
const NotificationLevel._(this.value);
|
||||
|
||||
/// The underlying value of this enum member.
|
||||
final String value;
|
||||
|
||||
@override
|
||||
String toString() => value;
|
||||
|
||||
String toJson() => value;
|
||||
|
||||
static const success = NotificationLevel._(r'success');
|
||||
static const error = NotificationLevel._(r'error');
|
||||
static const warning = NotificationLevel._(r'warning');
|
||||
static const info = NotificationLevel._(r'info');
|
||||
|
||||
/// List of all possible values in this [enum][NotificationLevel].
|
||||
static const values = <NotificationLevel>[
|
||||
success,
|
||||
error,
|
||||
warning,
|
||||
info,
|
||||
];
|
||||
|
||||
static NotificationLevel? fromJson(dynamic value) => NotificationLevelTypeTransformer().decode(value);
|
||||
|
||||
static List<NotificationLevel> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <NotificationLevel>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = NotificationLevel.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [NotificationLevel] to String,
|
||||
/// and [decode] dynamic data back to [NotificationLevel].
|
||||
class NotificationLevelTypeTransformer {
|
||||
factory NotificationLevelTypeTransformer() => _instance ??= const NotificationLevelTypeTransformer._();
|
||||
|
||||
const NotificationLevelTypeTransformer._();
|
||||
|
||||
String encode(NotificationLevel data) => data.value;
|
||||
|
||||
/// Decodes a [dynamic value][data] to a NotificationLevel.
|
||||
///
|
||||
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
|
||||
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
|
||||
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
NotificationLevel? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data) {
|
||||
case r'success': return NotificationLevel.success;
|
||||
case r'error': return NotificationLevel.error;
|
||||
case r'warning': return NotificationLevel.warning;
|
||||
case r'info': return NotificationLevel.info;
|
||||
default:
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Singleton [NotificationLevelTypeTransformer] instance.
|
||||
static NotificationLevelTypeTransformer? _instance;
|
||||
}
|
||||
|
||||
91
mobile/openapi/lib/model/notification_type.dart
generated
Normal file
91
mobile/openapi/lib/model/notification_type.dart
generated
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.18
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
class NotificationType {
|
||||
/// Instantiate a new enum with the provided [value].
|
||||
const NotificationType._(this.value);
|
||||
|
||||
/// The underlying value of this enum member.
|
||||
final String value;
|
||||
|
||||
@override
|
||||
String toString() => value;
|
||||
|
||||
String toJson() => value;
|
||||
|
||||
static const jobFailed = NotificationType._(r'JobFailed');
|
||||
static const backupFailed = NotificationType._(r'BackupFailed');
|
||||
static const systemMessage = NotificationType._(r'SystemMessage');
|
||||
static const custom = NotificationType._(r'Custom');
|
||||
|
||||
/// List of all possible values in this [enum][NotificationType].
|
||||
static const values = <NotificationType>[
|
||||
jobFailed,
|
||||
backupFailed,
|
||||
systemMessage,
|
||||
custom,
|
||||
];
|
||||
|
||||
static NotificationType? fromJson(dynamic value) => NotificationTypeTypeTransformer().decode(value);
|
||||
|
||||
static List<NotificationType> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <NotificationType>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = NotificationType.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [NotificationType] to String,
|
||||
/// and [decode] dynamic data back to [NotificationType].
|
||||
class NotificationTypeTypeTransformer {
|
||||
factory NotificationTypeTypeTransformer() => _instance ??= const NotificationTypeTypeTransformer._();
|
||||
|
||||
const NotificationTypeTypeTransformer._();
|
||||
|
||||
String encode(NotificationType data) => data.value;
|
||||
|
||||
/// Decodes a [dynamic value][data] to a NotificationType.
|
||||
///
|
||||
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
|
||||
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
|
||||
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
NotificationType? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data) {
|
||||
case r'JobFailed': return NotificationType.jobFailed;
|
||||
case r'BackupFailed': return NotificationType.backupFailed;
|
||||
case r'SystemMessage': return NotificationType.systemMessage;
|
||||
case r'Custom': return NotificationType.custom;
|
||||
default:
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Singleton [NotificationTypeTypeTransformer] instance.
|
||||
static NotificationTypeTypeTransformer? _instance;
|
||||
}
|
||||
|
||||
112
mobile/openapi/lib/model/notification_update_all_dto.dart
generated
Normal file
112
mobile/openapi/lib/model/notification_update_all_dto.dart
generated
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.18
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class NotificationUpdateAllDto {
|
||||
/// Returns a new [NotificationUpdateAllDto] instance.
|
||||
NotificationUpdateAllDto({
|
||||
this.ids = const [],
|
||||
this.readAt,
|
||||
});
|
||||
|
||||
List<String> ids;
|
||||
|
||||
DateTime? readAt;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is NotificationUpdateAllDto &&
|
||||
_deepEquality.equals(other.ids, ids) &&
|
||||
other.readAt == readAt;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(ids.hashCode) +
|
||||
(readAt == null ? 0 : readAt!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'NotificationUpdateAllDto[ids=$ids, readAt=$readAt]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
json[r'ids'] = this.ids;
|
||||
if (this.readAt != null) {
|
||||
json[r'readAt'] = this.readAt!.toUtc().toIso8601String();
|
||||
} else {
|
||||
// json[r'readAt'] = null;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [NotificationUpdateAllDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static NotificationUpdateAllDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "NotificationUpdateAllDto");
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return NotificationUpdateAllDto(
|
||||
ids: json[r'ids'] is Iterable
|
||||
? (json[r'ids'] as Iterable).cast<String>().toList(growable: false)
|
||||
: const [],
|
||||
readAt: mapDateTime(json, r'readAt', r''),
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<NotificationUpdateAllDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <NotificationUpdateAllDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = NotificationUpdateAllDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, NotificationUpdateAllDto> mapFromJson(dynamic json) {
|
||||
final map = <String, NotificationUpdateAllDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = NotificationUpdateAllDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of NotificationUpdateAllDto-objects as value to a dart map
|
||||
static Map<String, List<NotificationUpdateAllDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<NotificationUpdateAllDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = NotificationUpdateAllDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'ids',
|
||||
};
|
||||
}
|
||||
|
||||
102
mobile/openapi/lib/model/notification_update_dto.dart
generated
Normal file
102
mobile/openapi/lib/model/notification_update_dto.dart
generated
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.18
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class NotificationUpdateDto {
|
||||
/// Returns a new [NotificationUpdateDto] instance.
|
||||
NotificationUpdateDto({
|
||||
this.readAt,
|
||||
});
|
||||
|
||||
DateTime? readAt;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is NotificationUpdateDto &&
|
||||
other.readAt == readAt;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(readAt == null ? 0 : readAt!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'NotificationUpdateDto[readAt=$readAt]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
if (this.readAt != null) {
|
||||
json[r'readAt'] = this.readAt!.toUtc().toIso8601String();
|
||||
} else {
|
||||
// json[r'readAt'] = null;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [NotificationUpdateDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static NotificationUpdateDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "NotificationUpdateDto");
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return NotificationUpdateDto(
|
||||
readAt: mapDateTime(json, r'readAt', r''),
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<NotificationUpdateDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <NotificationUpdateDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = NotificationUpdateDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, NotificationUpdateDto> mapFromJson(dynamic json) {
|
||||
final map = <String, NotificationUpdateDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = NotificationUpdateDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of NotificationUpdateDto-objects as value to a dart map
|
||||
static Map<String, List<NotificationUpdateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<NotificationUpdateDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = NotificationUpdateDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
12
mobile/openapi/lib/model/permission.dart
generated
12
mobile/openapi/lib/model/permission.dart
generated
|
|
@ -66,6 +66,10 @@ class Permission {
|
|||
static const memoryPeriodRead = Permission._(r'memory.read');
|
||||
static const memoryPeriodUpdate = Permission._(r'memory.update');
|
||||
static const memoryPeriodDelete = Permission._(r'memory.delete');
|
||||
static const notificationPeriodCreate = Permission._(r'notification.create');
|
||||
static const notificationPeriodRead = Permission._(r'notification.read');
|
||||
static const notificationPeriodUpdate = Permission._(r'notification.update');
|
||||
static const notificationPeriodDelete = Permission._(r'notification.delete');
|
||||
static const partnerPeriodCreate = Permission._(r'partner.create');
|
||||
static const partnerPeriodRead = Permission._(r'partner.read');
|
||||
static const partnerPeriodUpdate = Permission._(r'partner.update');
|
||||
|
|
@ -147,6 +151,10 @@ class Permission {
|
|||
memoryPeriodRead,
|
||||
memoryPeriodUpdate,
|
||||
memoryPeriodDelete,
|
||||
notificationPeriodCreate,
|
||||
notificationPeriodRead,
|
||||
notificationPeriodUpdate,
|
||||
notificationPeriodDelete,
|
||||
partnerPeriodCreate,
|
||||
partnerPeriodRead,
|
||||
partnerPeriodUpdate,
|
||||
|
|
@ -263,6 +271,10 @@ class PermissionTypeTransformer {
|
|||
case r'memory.read': return Permission.memoryPeriodRead;
|
||||
case r'memory.update': return Permission.memoryPeriodUpdate;
|
||||
case r'memory.delete': return Permission.memoryPeriodDelete;
|
||||
case r'notification.create': return Permission.notificationPeriodCreate;
|
||||
case r'notification.read': return Permission.notificationPeriodRead;
|
||||
case r'notification.update': return Permission.notificationPeriodUpdate;
|
||||
case r'notification.delete': return Permission.notificationPeriodDelete;
|
||||
case r'partner.create': return Permission.partnerPeriodCreate;
|
||||
case r'partner.read': return Permission.partnerPeriodRead;
|
||||
case r'partner.update': return Permission.partnerPeriodUpdate;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue