2019-02-21 11:51:49 +01:00
|
|
|
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 {
|
2019-02-21 15:36:19 +01:00
|
|
|
String platform;
|
2019-02-21 11:51:49 +01:00
|
|
|
String domain;
|
2019-09-26 16:14:14 +02:00
|
|
|
String token;
|
2019-02-21 15:36:19 +01:00
|
|
|
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-02-21 11:51:49 +01:00
|
|
|
|
2019-09-27 14:52:38 +02:00
|
|
|
Account({
|
2019-09-26 16:14:14 +02:00
|
|
|
@required this.platform,
|
|
|
|
@required this.domain,
|
2019-02-21 11:51:49 +01:00
|
|
|
@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-02-21 11:51:49 +01:00
|
|
|
});
|
|
|
|
|
2019-09-27 14:52:38 +02:00
|
|
|
factory Account.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$AccountFromJson(json);
|
2019-02-21 11:51:49 +01:00
|
|
|
|
2019-09-27 14:52:38 +02:00
|
|
|
Map<String, dynamic> toJson() => _$AccountToJson(this);
|
2019-02-21 11:51:49 +01:00
|
|
|
}
|