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

147 lines
3.6 KiB
Dart
Raw Normal View History

2020-02-02 07:08:58 +01:00
import 'package:json_annotation/json_annotation.dart';
part 'bitbucket.g.dart';
2020-02-02 09:40:12 +01:00
@JsonSerializable(fieldRename: FieldRename.snake)
class BbPagination {
int pagelen;
int size;
int page;
String next;
List values;
BbPagination();
factory BbPagination.fromJson(Map<String, dynamic> json) =>
_$BbPaginationFromJson(json);
}
2020-02-02 07:08:58 +01:00
@JsonSerializable(fieldRename: FieldRename.snake)
2020-02-02 11:58:05 +01:00
class BbRepoOwner {
2020-02-02 09:40:12 +01:00
String nickname;
2020-02-02 07:08:58 +01:00
String displayName;
2020-02-02 09:40:12 +01:00
String type; // user, team
2020-02-02 07:24:22 +01:00
Map<String, dynamic> links;
String get avatarUrl => links['avatar']['href'];
2020-02-02 11:58:05 +01:00
BbRepoOwner();
factory BbRepoOwner.fromJson(Map<String, dynamic> json) =>
_$BbRepoOwnerFromJson(json);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class BbUser extends BbRepoOwner {
String username;
bool isStaff;
DateTime createdOn;
String accountId;
2020-02-02 07:08:58 +01:00
BbUser();
factory BbUser.fromJson(Map<String, dynamic> json) => _$BbUserFromJson(json);
}
2020-02-02 09:40:12 +01:00
@JsonSerializable(fieldRename: FieldRename.snake)
class BbRepo {
String name;
2020-02-02 11:58:05 +01:00
BbRepoOwner owner;
2020-02-02 09:40:12 +01:00
String website;
String language;
int size;
String type; // repository
bool isPrivate;
DateTime createdOn;
DateTime updatedOn;
String description;
String fullName;
2020-02-02 11:58:05 +01:00
String slug;
BbRepoMainbranch mainbranch;
2020-02-02 09:40:12 +01:00
Map<String, dynamic> links;
2020-02-02 12:06:48 +01:00
String get ownerLogin => fullName.split('/')[0]; // owner has no username
2020-02-02 09:40:12 +01:00
String get avatarUrl => links['avatar']['href'];
BbRepo();
factory BbRepo.fromJson(Map<String, dynamic> json) => _$BbRepoFromJson(json);
}
2020-02-02 11:58:05 +01:00
@JsonSerializable(fieldRename: FieldRename.snake)
class BbRepoMainbranch {
String type;
String name;
BbRepoMainbranch();
factory BbRepoMainbranch.fromJson(Map<String, dynamic> json) =>
_$BbRepoMainbranchFromJson(json);
}
2020-02-02 12:50:00 +01:00
@JsonSerializable(fieldRename: FieldRename.snake)
class BbTree {
String type;
String path;
int size;
2020-02-02 16:02:58 +01:00
Map<String, dynamic> links;
2020-02-02 12:50:00 +01:00
BbTree();
factory BbTree.fromJson(Map<String, dynamic> json) => _$BbTreeFromJson(json);
}
2020-02-03 07:40:56 +01:00
@JsonSerializable(fieldRename: FieldRename.snake)
class BbCommit {
String message;
DateTime date;
String hash;
BbCommitAuthor author;
BbCommit();
factory BbCommit.fromJson(Map<String, dynamic> json) =>
_$BbCommitFromJson(json);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class BbCommitAuthor {
String raw;
BbRepoOwner user;
BbCommitAuthor();
factory BbCommitAuthor.fromJson(Map<String, dynamic> json) =>
_$BbCommitAuthorFromJson(json);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class BbIssues {
String priority;
String state;
BbRepo repository;
String title;
BbRepoOwner reporter;
DateTime createdOn;
Map<String, dynamic> links;
String get issueLink => links['self']['href'];
BbIssues();
factory BbIssues.fromJson(Map<String, dynamic> json) =>
_$BbIssuesFromJson(json);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class BbPulls {
String description;
BbRepoOwner author;
String title;
Map<String, dynamic> links;
String get pullRequestLink => links['self']['href'];
DateTime createdOn;
BbPulls();
factory BbPulls.fromJson(Map<String, dynamic> json) =>
_$BbPullsFromJson(json);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class BbCommentContent {
String raw;
String markup;
String html;
BbCommentContent();
factory BbCommentContent.fromJson(Map<String, dynamic> json) =>
_$BbCommentContentFromJson(json);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class BbComment {
String createdOn;
String updatedOn;
BbCommentContent content;
BbRepoOwner user;
BbComment();
factory BbComment.fromJson(Map<String, dynamic> json) =>
_$BbCommentFromJson(json);
}