mirror of
https://github.com/pd4d10/git-touch.git
synced 2026-04-28 18:39:26 -05:00
feat: gitea api
This commit is contained in:
@@ -140,6 +140,13 @@ class AuthModel with ChangeNotifier {
|
||||
return info;
|
||||
}
|
||||
|
||||
Future fetchGitea(String p) async {
|
||||
final res = await http.get('https://try.gitea.io' + '/api/v1' + p,
|
||||
headers: {'Authorization': ''});
|
||||
final info = json.decode(utf8.decode(res.bodyBytes));
|
||||
return info;
|
||||
}
|
||||
|
||||
Future<void> init() async {
|
||||
// Listen scheme
|
||||
_sub = getUriLinksStream().listen(_onSchemeDetected, onError: (err) {
|
||||
|
||||
31
lib/models/gitea.dart
Normal file
31
lib/models/gitea.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'gitea.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class GiteaUser {
|
||||
int id;
|
||||
String login;
|
||||
String fullName;
|
||||
String avatarUrl;
|
||||
|
||||
GiteaUser();
|
||||
|
||||
factory GiteaUser.fromJson(Map<String, dynamic> json) =>
|
||||
_$GiteaUserFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class GiteaRepository {
|
||||
int id;
|
||||
GiteaUser owner;
|
||||
String name;
|
||||
String description;
|
||||
int starsCount;
|
||||
int forksCount;
|
||||
|
||||
GiteaRepository();
|
||||
|
||||
factory GiteaRepository.fromJson(Map<String, dynamic> json) =>
|
||||
_$GiteaRepositoryFromJson(json);
|
||||
}
|
||||
44
lib/models/gitea.g.dart
Normal file
44
lib/models/gitea.g.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'gitea.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
GiteaUser _$GiteaUserFromJson(Map<String, dynamic> json) {
|
||||
return GiteaUser()
|
||||
..id = json['id'] as int
|
||||
..login = json['login'] as String
|
||||
..fullName = json['full_name'] as String
|
||||
..avatarUrl = json['avatar_url'] as String;
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$GiteaUserToJson(GiteaUser instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'login': instance.login,
|
||||
'full_name': instance.fullName,
|
||||
'avatar_url': instance.avatarUrl,
|
||||
};
|
||||
|
||||
GiteaRepository _$GiteaRepositoryFromJson(Map<String, dynamic> json) {
|
||||
return GiteaRepository()
|
||||
..id = json['id'] as int
|
||||
..owner = json['owner'] == null
|
||||
? null
|
||||
: GiteaUser.fromJson(json['owner'] as Map<String, dynamic>)
|
||||
..name = json['name'] as String
|
||||
..description = json['description'] as String
|
||||
..starsCount = json['starsCount'] as int
|
||||
..forksCount = json['forksCount'] as int;
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$GiteaRepositoryToJson(GiteaRepository instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'owner': instance.owner,
|
||||
'name': instance.name,
|
||||
'description': instance.description,
|
||||
'starsCount': instance.starsCount,
|
||||
'forksCount': instance.forksCount,
|
||||
};
|
||||
Reference in New Issue
Block a user