refactor(github): use rest api for download_url

This commit is contained in:
Rongjian Zhang
2020-01-31 14:09:00 +08:00
parent 16925f8e1a
commit 05a4ffeeb8
4 changed files with 90 additions and 74 deletions

View File

@@ -235,3 +235,16 @@ class GithubTrendingUserRepo {
factory GithubTrendingUserRepo.fromJson(Map<String, dynamic> json) =>
_$GithubTrendingUserRepoFromJson(json);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class GithubTreeItem {
String name;
String path;
int size;
String type;
String downloadUrl;
String content;
GithubTreeItem();
factory GithubTreeItem.fromJson(Map<String, dynamic> json) =>
_$GithubTreeItemFromJson(json);
}

View File

@@ -278,3 +278,23 @@ Map<String, dynamic> _$GithubTrendingUserRepoToJson(
'name': instance.name,
'description': instance.description,
};
GithubTreeItem _$GithubTreeItemFromJson(Map<String, dynamic> json) {
return GithubTreeItem()
..name = json['name'] as String
..path = json['path'] as String
..size = json['size'] as int
..type = json['type'] as String
..downloadUrl = json['download_url'] as String
..content = json['content'] as String;
}
Map<String, dynamic> _$GithubTreeItemToJson(GithubTreeItem instance) =>
<String, dynamic>{
'name': instance.name,
'path': instance.path,
'size': instance.size,
'type': instance.type,
'download_url': instance.downloadUrl,
'content': instance.content,
};