import 'dart:async'; import 'package:vikunja_app/api/client.dart'; import 'package:vikunja_app/api/service.dart'; import 'package:vikunja_app/models/list.dart'; import 'package:vikunja_app/service/services.dart'; class ListAPIService extends APIService implements ListService { ListAPIService(Client client) : super(client); @override Future create(namespaceId, TaskList tl) { return client .put('/namespaces/$namespaceId/lists', body: tl.toJSON()) .then((response) => TaskList.fromJson(response.body)); } @override Future delete(int listId) { return client.delete('/lists/$listId').then((_) {}); } @override Future get(int listId) { return client .get('/lists/$listId') .then((response) => TaskList.fromJson(response.body)); } @override Future> getAll() { return client.get('/lists').then((response) => convertList(response.body, (result) => TaskList.fromJson(result))); } @override Future> getByNamespace(int namespaceId) { return client.get('/namespaces/$namespaceId/lists').then((response) => convertList(response.body, (result) => TaskList.fromJson(result))); } @override Future update(TaskList tl) { return client .post('/lists/${tl.id}', body: tl.toJSON()) .then((response) => TaskList.fromJson(response.body)); } }