GiteaClient/lib/model/issues.dart
Bazsalanszky e437f99a79
All checks were successful
ci/woodpecker/push/flutterBuild Pipeline was successful
Bloc for Issues
2022-05-22 10:28:34 +02:00

339 lines
8.4 KiB
Dart

import 'package:gitea_client/model/user.dart';
class Issue {
int? id;
String? url;
String? htmlUrl;
int? number;
_User? user;
String? originalAuthor;
int? originalAuthorId;
String? title;
String? body;
String? ref;
List<Labels>? labels;
Milestone? milestone;
_User? assignee;
List<_User>? assignees;
String? state;
bool? isLocked;
int? comments;
String? createdAt;
String? updatedAt;
String? closedAt;
String? dueDate;
String? pullRequest;
_Repository? repository;
Issue(
{this.id,
this.url,
this.htmlUrl,
this.number,
this.user,
this.originalAuthor,
this.originalAuthorId,
this.title,
this.body,
this.ref,
this.labels,
this.milestone,
this.assignee,
this.assignees,
this.state,
this.isLocked,
this.comments,
this.createdAt,
this.updatedAt,
this.closedAt,
this.dueDate,
this.pullRequest,
this.repository});
Issue.fromJson(Map<String, dynamic> json) {
id = json['id'];
url = json['url'];
htmlUrl = json['html_url'];
number = json['number'];
user = json['user'] != null ? _User.fromJson(json['user']) : null;
originalAuthor = json['original_author'];
originalAuthorId = json['original_author_id'];
title = json['title'];
body = json['body'];
ref = json['ref'];
if (json['labels'] != null) {
labels = <Labels>[];
json['labels'].forEach((v) {
labels!.add(Labels.fromJson(v));
});
}
milestone = json['milestone'] != null
? Milestone.fromJson(json['milestone'])
: null;
assignee =
json['assignee'] != null ? _User.fromJson(json['assignee']) : null;
if (json['assignees'] != null) {
assignees = <_User>[];
json['assignees'].forEach((v) {
assignees!.add(_User.fromJson(v));
});
}
state = json['state'];
isLocked = json['is_locked'];
comments = json['comments'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
closedAt = json['closed_at'];
dueDate = json['due_date'];
pullRequest = json['pull_request'];
repository = json['repository'] != null
? _Repository.fromJson(json['repository'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['url'] = url;
data['html_url'] = htmlUrl;
data['number'] = number;
if (user != null) {
data['user'] = user!.toJson();
}
data['original_author'] = originalAuthor;
data['original_author_id'] = originalAuthorId;
data['title'] = title;
data['body'] = body;
data['ref'] = ref;
if (labels != null) {
data['labels'] = labels!.map((v) => v.toJson()).toList();
}
if (milestone != null) {
data['milestone'] = milestone!.toJson();
}
if (assignee != null) {
data['assignee'] = assignee!.toJson();
}
if (assignees != null) {
data['assignees'] = assignees!.map((v) => v.toJson()).toList();
}
data['state'] = state;
data['is_locked'] = isLocked;
data['comments'] = comments;
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
data['closed_at'] = closedAt;
data['due_date'] = dueDate;
data['pull_request'] = pullRequest;
if (repository != null) {
data['repository'] = repository!.toJson();
}
return data;
}
}
class _User {
int? id;
String? login;
String? fullName;
String? email;
String? avatarUrl;
String? language;
bool? isAdmin;
String? lastLogin;
String? created;
bool? restricted;
bool? active;
bool? prohibitLogin;
String? location;
String? website;
String? description;
String? visibility;
int? followersCount;
int? followingCount;
int? starredReposCount;
String? username;
_User(
{this.id,
this.login,
this.fullName,
this.email,
this.avatarUrl,
this.language,
this.isAdmin,
this.lastLogin,
this.created,
this.restricted,
this.active,
this.prohibitLogin,
this.location,
this.website,
this.description,
this.visibility,
this.followersCount,
this.followingCount,
this.starredReposCount,
this.username});
_User.fromJson(Map<String, dynamic> json) {
id = json['id'];
login = json['login'];
fullName = json['full_name'];
email = json['email'];
avatarUrl = json['avatar_url'];
language = json['language'];
isAdmin = json['is_admin'];
lastLogin = json['last_login'];
created = json['created'];
restricted = json['restricted'];
active = json['active'];
prohibitLogin = json['prohibit_login'];
location = json['location'];
website = json['website'];
description = json['description'];
visibility = json['visibility'];
followersCount = json['followers_count'];
followingCount = json['following_count'];
starredReposCount = json['starred_repos_count'];
username = json['username'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['login'] = login;
data['full_name'] = fullName;
data['email'] = email;
data['avatar_url'] = avatarUrl;
data['language'] = language;
data['is_admin'] = isAdmin;
data['last_login'] = lastLogin;
data['created'] = created;
data['restricted'] = restricted;
data['active'] = active;
data['prohibit_login'] = prohibitLogin;
data['location'] = location;
data['website'] = website;
data['description'] = description;
data['visibility'] = visibility;
data['followers_count'] = followersCount;
data['following_count'] = followingCount;
data['starred_repos_count'] = starredReposCount;
data['username'] = username;
return data;
}
}
class Labels {
int id;
String name;
String color;
String description;
String url;
Labels(
{required this.id,
required this.name,
required this.color,
required this.description,
required this.url});
Labels.fromJson(Map<String, dynamic> json)
: id = json['id'],
name = json['name'],
color = json['color'],
description = json['description'],
url = json['url'];
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['color'] = color;
data['description'] = description;
data['url'] = url;
return data;
}
}
class Milestone {
int id;
String title;
String description;
String state;
int openIssues;
int closedIssues;
String createdAt;
String updatedAt;
String? closedAt;
String? dueOn;
Milestone(
{required this.id,
required this.title,
required this.description,
required this.state,
required this.openIssues,
required this.closedIssues,
required this.createdAt,
required this.updatedAt,
this.closedAt,
this.dueOn});
Milestone.fromJson(Map<String, dynamic> json)
: id = json['id'],
title = json['title'],
description = json['description'],
state = json['state'],
openIssues = json['open_issues'],
closedIssues = json['closed_issues'],
createdAt = json['created_at'],
updatedAt = json['updated_at'] {
closedAt = json['closed_at'];
dueOn = json['due_on'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['title'] = title;
data['description'] = description;
data['state'] = state;
data['open_issues'] = openIssues;
data['closed_issues'] = closedIssues;
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
data['closed_at'] = closedAt;
data['due_on'] = dueOn;
return data;
}
}
class _Repository {
int id;
String name;
String owner;
String fullName;
_Repository(
{required this.id,
required this.name,
required this.owner,
required this.fullName});
_Repository.fromJson(Map<String, dynamic> json)
: id = json['id'],
name = json['name'],
owner = json['owner'],
fullName = json['full_name'];
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['owner'] = owner;
data['full_name'] = fullName;
return data;
}
}