1
0
mirror of https://github.com/go-vikunja/app synced 2024-11-08 05:50:00 +00:00
app-mirror-github/lib/api/labels.dart

51 lines
1.5 KiB
Dart
Raw Normal View History

2021-06-04 09:34:25 +00:00
import 'package:vikunja_app/api/client.dart';
import 'package:vikunja_app/api/service.dart';
import 'package:vikunja_app/models/label.dart';
import 'package:vikunja_app/service/services.dart';
class LabelAPIService extends APIService implements LabelService {
LabelAPIService(Client client) : super(client);
@override
Future<Label?> create(Label label) {
return client.put('/labels', body: label.toJSON()).then((response) {
if (response == null) return null;
return Label.fromJson(response.body);
});
2021-06-04 09:34:25 +00:00
}
@override
Future<Label?> delete(Label label) {
return client.delete('/labels/${label.id}').then((response) {
if (response == null) return null;
return Label.fromJson(response.body);
});
2021-06-04 09:34:25 +00:00
}
@override
Future<Label?> get(int labelID) {
return client.get('/labels/$labelID').then((response) {
if (response == null) return null;
return Label.fromJson(response.body);
});
2021-06-04 09:34:25 +00:00
}
@override
Future<List<Label>?> getAll({String? query}) {
2022-09-03 15:43:16 +00:00
String params =
query == null ? '' : '?s=' + Uri.encodeQueryComponent(query);
return client.get('/labels$params').then((response) {
if (response == null) return null;
return convertList(response.body, (result) => Label.fromJson(result));
});
2021-06-04 09:34:25 +00:00
}
@override
Future<Label?> update(Label label) {
return client.post('/labels/${label.id}', body: label).then((response) {
if (response == null) return null;
return Label.fromJson(response.body);
});
2021-06-04 09:34:25 +00:00
}
}