git-touch-android-ios-app/lib/models/account.dart

41 lines
914 B
Dart
Raw Normal View History

import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'account.g.dart';
@JsonSerializable()
2019-09-27 14:52:38 +02:00
class Account {
String platform;
String domain;
2019-09-26 16:14:14 +02:00
String token;
String login;
2019-09-26 16:14:14 +02:00
String avatarUrl;
2019-12-30 13:50:31 +01:00
int gitlabId;
2019-09-26 16:14:14 +02:00
2019-09-27 14:52:38 +02:00
equals(Account a) {
2019-09-26 16:40:53 +02:00
final uri = Uri.parse(domain);
final uriA = Uri.parse(a.domain);
// Treat domains as the same if they have the same hosts and ports
return a.platform == platform &&
a.login == login &&
2019-12-30 13:50:31 +01:00
a.gitlabId == gitlabId &&
2019-09-26 16:40:53 +02:00
uri.host == uriA.host &&
uri.port == uriA.port;
}
2019-09-27 14:52:38 +02:00
Account({
2019-09-26 16:14:14 +02:00
@required this.platform,
@required this.domain,
@required this.token,
2019-09-26 16:14:14 +02:00
@required this.login,
@required this.avatarUrl,
2019-12-30 13:50:31 +01:00
this.gitlabId,
});
2019-09-27 14:52:38 +02:00
factory Account.fromJson(Map<String, dynamic> json) =>
_$AccountFromJson(json);
2019-09-27 14:52:38 +02:00
Map<String, dynamic> toJson() => _$AccountToJson(this);
}