GiteaClient/lib/model/pull.dart
Balazs Toldi aed1d96a21
All checks were successful
ci/woodpecker/pr/flutterBuild Pipeline was successful
Fixed some bugs and added more locales
2022-05-22 22:02:06 +02:00

235 lines
6.2 KiB
Dart

import 'package:gitea_client/model/repository.dart';
import 'package:gitea_client/model/user.dart';
import 'issues.dart';
class PullRequest {
int id;
String url;
int number;
User user;
String title;
String body;
List<Labels>? labels;
Milestone? milestone;
User? assignee;
List<User>? assignees;
String state;
bool isLocked;
int comments;
String htmlUrl;
String diffUrl;
String patchUrl;
bool? mergeable;
bool merged;
String? mergedAt;
String? mergeCommitSha;
User? mergedBy;
bool? allowMaintainerEdit;
Base? base;
Base? head;
String? mergeBase;
String? dueDate;
String createdAt;
String updatedAt;
String? closedAt;
PullRequest(
{required this.id,
required this.url,
required this.number,
required this.user,
required this.title,
required this.body,
this.labels,
this.milestone,
this.assignee,
this.assignees,
required this.state,
required this.isLocked,
required this.comments,
required this.htmlUrl,
required this.diffUrl,
required this.patchUrl,
this.mergeable,
required this.merged,
this.mergedAt,
this.mergeCommitSha,
this.mergedBy,
this.allowMaintainerEdit,
this.base,
this.head,
this.mergeBase,
this.dueDate,
required this.createdAt,
required this.updatedAt,
this.closedAt});
PullRequest.fromJson(Map<String, dynamic> json)
: id = json['id'],
url = json['url'],
number = json['number'],
user = User.fromJson(json['user']),
title = json['title'],
body = json['body'],
comments = json['comments'],
htmlUrl = json['html_url'],
diffUrl = json['diff_url'],
createdAt = json['created_at'],
updatedAt = json['updated_at'],
state = json['state'],
isLocked = json['is_locked'],
patchUrl = json['patch_url'],
merged = json['merged'] {
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));
});
}
mergeable = json['mergeable'];
mergedAt = json['merged_at'];
mergeCommitSha = json['merge_commit_sha'];
mergedBy =
json['merged_by'] != null ? User.fromJson(json['merged_by']) : null;
allowMaintainerEdit = json['allow_maintainer_edit'];
base = json['base'] != null ? Base.fromJson(json['base']) : null;
head = json['head'] != null ? Base.fromJson(json['head']) : null;
mergeBase = json['merge_base'];
dueDate = json['due_date'];
closedAt = json['closed_at'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['url'] = url;
data['number'] = number;
data['user'] = user.toJson();
data['title'] = title;
data['body'] = body;
if (labels != null) {
data['labels'] = labels!.map((v) => v.toJson()).toList();
}
if (milestone != null) {
data['milestone'] = milestone!.toJson();
}
data['assignee'] = assignee;
data['assignees'] = assignees;
data['state'] = state;
data['is_locked'] = isLocked;
data['comments'] = comments;
data['html_url'] = htmlUrl;
data['diff_url'] = diffUrl;
data['patch_url'] = patchUrl;
data['mergeable'] = mergeable;
data['merged'] = merged;
data['merged_at'] = mergedAt;
data['merge_commit_sha'] = mergeCommitSha;
if (mergedBy != null) {
data['merged_by'] = mergedBy!.toJson();
}
data['allow_maintainer_edit'] = allowMaintainerEdit;
if (base != null) {
data['base'] = base!.toJson();
}
if (head != null) {
data['head'] = head!.toJson();
}
data['merge_base'] = mergeBase;
data['due_date'] = dueDate;
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
data['closed_at'] = closedAt;
return data;
}
}
class Base {
String? label;
String? ref;
String? sha;
int? repoId;
Repository? repo;
Base({this.label, this.ref, this.sha, this.repoId, this.repo});
Base.fromJson(Map<String, dynamic> json) {
label = json['label'];
ref = json['ref'];
sha = json['sha'];
repoId = json['repo_id'];
repo = json['repo'] != null ? Repository.fromJson(json['repo']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['label'] = label;
data['ref'] = ref;
data['sha'] = sha;
data['repo_id'] = repoId;
if (repo != null) {
data['repo'] = repo!.toJson();
}
return data;
}
}
class Permissions {
bool? admin;
bool? push;
bool? pull;
Permissions({this.admin, this.push, this.pull});
Permissions.fromJson(Map<String, dynamic> json) {
admin = json['admin'];
push = json['push'];
pull = json['pull'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['admin'] = admin;
data['push'] = push;
data['pull'] = pull;
return data;
}
}
class InternalTracker {
bool? enableTimeTracker;
bool? allowOnlyContributorsToTrackTime;
bool? enableIssueDependencies;
InternalTracker(
{this.enableTimeTracker,
this.allowOnlyContributorsToTrackTime,
this.enableIssueDependencies});
InternalTracker.fromJson(Map<String, dynamic> json) {
enableTimeTracker = json['enable_time_tracker'];
allowOnlyContributorsToTrackTime =
json['allow_only_contributors_to_track_time'];
enableIssueDependencies = json['enable_issue_dependencies'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['enable_time_tracker'] = enableTimeTracker;
data['allow_only_contributors_to_track_time'] =
allowOnlyContributorsToTrackTime;
data['enable_issue_dependencies'] = enableIssueDependencies;
return data;
}
}