import 'package:json_annotation/json_annotation.dart'; part 'bitbucket.g.dart'; @JsonSerializable(fieldRename: FieldRename.snake) class BbPagination { int pagelen; int size; int page; String next; List values; BbPagination(); factory BbPagination.fromJson(Map json) => _$BbPaginationFromJson(json); } @JsonSerializable(fieldRename: FieldRename.snake) class BbRepoOwner { String nickname; String displayName; String type; // user, team Map links; String get avatarUrl => links['avatar']['href']; BbRepoOwner(); factory BbRepoOwner.fromJson(Map json) => _$BbRepoOwnerFromJson(json); } @JsonSerializable(fieldRename: FieldRename.snake) class BbUser extends BbRepoOwner { String username; bool isStaff; DateTime createdOn; BbUser(); factory BbUser.fromJson(Map json) => _$BbUserFromJson(json); } @JsonSerializable(fieldRename: FieldRename.snake) class BbRepo { String name; BbRepoOwner owner; String website; String language; int size; String type; // repository bool isPrivate; DateTime createdOn; DateTime updatedOn; String description; String fullName; String slug; BbRepoMainbranch mainbranch; Map links; String get ownerLogin => fullName.split('/')[0]; // owner has no username String get avatarUrl => links['avatar']['href']; BbRepo(); factory BbRepo.fromJson(Map json) => _$BbRepoFromJson(json); } @JsonSerializable(fieldRename: FieldRename.snake) class BbRepoMainbranch { String type; String name; BbRepoMainbranch(); factory BbRepoMainbranch.fromJson(Map json) => _$BbRepoMainbranchFromJson(json); } @JsonSerializable(fieldRename: FieldRename.snake) class BbTree { String type; String path; int size; Map links; BbTree(); factory BbTree.fromJson(Map json) => _$BbTreeFromJson(json); } @JsonSerializable(fieldRename: FieldRename.snake) class BbCommit { String message; DateTime date; String hash; BbCommitAuthor author; BbCommit(); factory BbCommit.fromJson(Map json) => _$BbCommitFromJson(json); } @JsonSerializable(fieldRename: FieldRename.snake) class BbCommitAuthor { String raw; BbRepoOwner user; BbCommitAuthor(); factory BbCommitAuthor.fromJson(Map json) => _$BbCommitAuthorFromJson(json); }