diff --git a/lib/src/data/repository/client.dart b/lib/src/data/repository/client.dart index 6d68cd5..1be04fb 100644 --- a/lib/src/data/repository/client.dart +++ b/lib/src/data/repository/client.dart @@ -90,4 +90,13 @@ class Client extends Repository { .map((e) => ProductModel.fromJSON(e)) .toList(); } + + @override + Future getProduct(String id) async { + Response response = await dio.get( + "$apiUrl/collections/products/records/$id", + options: options, + ); + return ProductModel.fromJSON(response.data); + } } diff --git a/lib/src/data/repository/repository.dart b/lib/src/data/repository/repository.dart index ae4f5d0..b6af244 100644 --- a/lib/src/data/repository/repository.dart +++ b/lib/src/data/repository/repository.dart @@ -27,4 +27,6 @@ abstract class Repository { Future> getProductList(); Future> searchProductList(String search); + + Future getProduct(String id); } diff --git a/lib/src/domain/use_cases/base_use_case.dart b/lib/src/domain/use_cases/base_use_case.dart index bcae1a0..a89f59e 100644 --- a/lib/src/domain/use_cases/base_use_case.dart +++ b/lib/src/domain/use_cases/base_use_case.dart @@ -82,4 +82,12 @@ class BaseUseCase { onError, ); } + + Future getProduct( + String id, + Function(ProductModel) onResponse, + Function(Exception) onError, + ) async { + await helper.request(() => client.getProduct(id), onResponse, onError); + } } diff --git a/test/matule_query_test.dart b/test/matule_query_test.dart index c8264b7..60a7ee1 100644 --- a/test/matule_query_test.dart +++ b/test/matule_query_test.dart @@ -21,6 +21,7 @@ onError(Exception e) { final String _email = "example@test.russ"; final String _password = "stringss"; +final String _productId = "45urlx4rj907rrk"; void main() { group("Query", () { @@ -65,5 +66,8 @@ void main() { test("SearchProductList", () async { await useCase.searchProductList("Рубашка Среда", onResponse, onError); }); + test("GetProduct", () async { + await useCase.getProduct(_productId, onResponse, onError); + }); }); }