mirror of
https://github.com/go-vikunja/app
synced 2024-06-05 03:59:48 +00:00
056b2d72c9
This PR formats all code with dart format and adds a step to the CI so that it will be checked on every push and PR.
50 lines
1.4 KiB
Dart
50 lines
1.4 KiB
Dart
import 'dart:async';
|
|
import 'dart:developer';
|
|
import 'package:vikunja_app/api/client.dart';
|
|
import 'package:vikunja_app/api/service.dart';
|
|
import 'package:vikunja_app/models/namespace.dart';
|
|
import 'package:vikunja_app/service/services.dart';
|
|
|
|
class NamespaceAPIService extends APIService implements NamespaceService {
|
|
NamespaceAPIService(Client client) : super(client);
|
|
|
|
@override
|
|
Future<Namespace?> create(Namespace ns) {
|
|
return client.put('/namespaces', body: ns.toJSON()).then((response) {
|
|
if (response == null) return null;
|
|
return Namespace.fromJson(response.body);
|
|
});
|
|
}
|
|
|
|
@override
|
|
Future delete(int namespaceId) {
|
|
return client.delete('/namespaces/$namespaceId');
|
|
}
|
|
|
|
@override
|
|
Future<Namespace?> get(int namespaceId) {
|
|
return client.get('/namespaces/$namespaceId').then((response) {
|
|
if (response == null) return null;
|
|
return Namespace.fromJson(response.body);
|
|
});
|
|
}
|
|
|
|
@override
|
|
Future<List<Namespace>?> getAll() {
|
|
return client.get('/namespaces').then((response) {
|
|
if (response == null) return null;
|
|
return convertList(response.body, (result) => Namespace.fromJson(result));
|
|
});
|
|
}
|
|
|
|
@override
|
|
Future<Namespace?> update(Namespace ns) {
|
|
return client
|
|
.post('/namespaces/${ns.id}', body: ns.toJSON())
|
|
.then((response) {
|
|
if (response == null) return null;
|
|
return Namespace.fromJson(response.body);
|
|
});
|
|
}
|
|
}
|