feature(collections): Заготовка под апи. Переключалка коллекций
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:remever/common/services/api_client.dart';
|
||||
import 'package:remever/database/database.dart';
|
||||
import 'package:remever/inject.dart';
|
||||
import 'package:remever/models/crud_collection_dto.dart';
|
||||
@@ -35,4 +37,37 @@ final class CollectionsService implements CollectionsInterface {
|
||||
// TODO: implement makeCollectionPublic
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> getCollectionsFromApi() async {
|
||||
try {
|
||||
final Response<dynamic> response = await apiClient.get(
|
||||
'/collections',
|
||||
queryParameters: <String, dynamic>{'perPage': 20, 'page': 1},
|
||||
);
|
||||
|
||||
print('data');
|
||||
} catch (e) {
|
||||
print('Response error $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> createCollectionApi() async {
|
||||
try {
|
||||
final Response<dynamic> response = await apiClient.post(
|
||||
'/collections',
|
||||
data: {
|
||||
"title": "Основы программирования для утюгов",
|
||||
"description":
|
||||
"Коллекция карточек по основам программирования для начинающих",
|
||||
"is_public": true,
|
||||
},
|
||||
);
|
||||
|
||||
print('data');
|
||||
} catch (e) {
|
||||
print('Response error $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user