1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-08 06:23:00 +02:00
Files
immich/mobile/lib/models/auth/auxilary_endpoint.model.dart
shenlong 5b0575b956 refactor: DCM - const border radius, constructor & switch expressions (#19515)
* enable border radius, switch exp, const constructor

* regenerate provider

* more formatting

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
2025-06-25 13:06:24 +05:30

106 lines
2.4 KiB
Dart

// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';
class AuxilaryEndpoint {
final String url;
final AuxCheckStatus status;
const AuxilaryEndpoint({
required this.url,
required this.status,
});
AuxilaryEndpoint copyWith({
String? url,
AuxCheckStatus? status,
}) {
return AuxilaryEndpoint(
url: url ?? this.url,
status: status ?? this.status,
);
}
@override
String toString() => 'AuxilaryEndpoint(url: $url, status: $status)';
@override
bool operator ==(covariant AuxilaryEndpoint other) {
if (identical(this, other)) return true;
return other.url == url && other.status == status;
}
@override
int get hashCode => url.hashCode ^ status.hashCode;
Map<String, dynamic> toMap() {
return <String, dynamic>{
'url': url,
'status': status.toMap(),
};
}
factory AuxilaryEndpoint.fromMap(Map<String, dynamic> map) {
return AuxilaryEndpoint(
url: map['url'] as String,
status: AuxCheckStatus.fromMap(map['status'] as Map<String, dynamic>),
);
}
String toJson() => json.encode(toMap());
factory AuxilaryEndpoint.fromJson(String source) =>
AuxilaryEndpoint.fromMap(json.decode(source) as Map<String, dynamic>);
}
class AuxCheckStatus {
final String name;
const AuxCheckStatus({
required this.name,
});
const AuxCheckStatus._(this.name);
static const loading = AuxCheckStatus._('loading');
static const valid = AuxCheckStatus._('valid');
static const error = AuxCheckStatus._('error');
static const unknown = AuxCheckStatus._('unknown');
@override
bool operator ==(covariant AuxCheckStatus other) {
if (identical(this, other)) return true;
return other.name == name;
}
@override
int get hashCode => name.hashCode;
AuxCheckStatus copyWith({
String? name,
}) {
return AuxCheckStatus(
name: name ?? this.name,
);
}
Map<String, dynamic> toMap() {
return <String, dynamic>{
'name': name,
};
}
factory AuxCheckStatus.fromMap(Map<String, dynamic> map) {
return AuxCheckStatus(
name: map['name'] as String,
);
}
String toJson() => json.encode(toMap());
factory AuxCheckStatus.fromJson(String source) =>
AuxCheckStatus.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() => 'AuxCheckStatus(name: $name)';
}