Получение описания товара-8

This commit is contained in:
PROF25-FINAL 2025-05-27 11:58:45 +03:00
parent e8269dae01
commit f68b50effd
4 changed files with 23 additions and 0 deletions

View File

@ -90,4 +90,13 @@ class Client extends Repository {
.map((e) => ProductModel.fromJSON(e))
.toList();
}
@override
Future<ProductModel> getProduct(String id) async {
Response response = await dio.get(
"$apiUrl/collections/products/records/$id",
options: options,
);
return ProductModel.fromJSON(response.data);
}
}

View File

@ -27,4 +27,6 @@ abstract class Repository {
Future<List<ProductModel>> getProductList();
Future<List<ProductModel>> searchProductList(String search);
Future<ProductModel> getProduct(String id);
}

View File

@ -82,4 +82,12 @@ class BaseUseCase {
onError,
);
}
Future<void> getProduct(
String id,
Function(ProductModel) onResponse,
Function(Exception) onError,
) async {
await helper.request(() => client.getProduct(id), onResponse, onError);
}
}

View File

@ -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);
});
});
}