Получение описания товара-8
This commit is contained in:
parent
e8269dae01
commit
f68b50effd
@ -90,4 +90,13 @@ class Client extends Repository {
|
|||||||
.map((e) => ProductModel.fromJSON(e))
|
.map((e) => ProductModel.fromJSON(e))
|
||||||
.toList();
|
.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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,4 +27,6 @@ abstract class Repository {
|
|||||||
Future<List<ProductModel>> getProductList();
|
Future<List<ProductModel>> getProductList();
|
||||||
|
|
||||||
Future<List<ProductModel>> searchProductList(String search);
|
Future<List<ProductModel>> searchProductList(String search);
|
||||||
|
|
||||||
|
Future<ProductModel> getProduct(String id);
|
||||||
}
|
}
|
||||||
|
@ -82,4 +82,12 @@ class BaseUseCase {
|
|||||||
onError,
|
onError,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> getProduct(
|
||||||
|
String id,
|
||||||
|
Function(ProductModel) onResponse,
|
||||||
|
Function(Exception) onError,
|
||||||
|
) async {
|
||||||
|
await helper.request(() => client.getProduct(id), onResponse, onError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ onError(Exception e) {
|
|||||||
|
|
||||||
final String _email = "example@test.russ";
|
final String _email = "example@test.russ";
|
||||||
final String _password = "stringss";
|
final String _password = "stringss";
|
||||||
|
final String _productId = "45urlx4rj907rrk";
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group("Query", () {
|
group("Query", () {
|
||||||
@ -65,5 +66,8 @@ void main() {
|
|||||||
test("SearchProductList", () async {
|
test("SearchProductList", () async {
|
||||||
await useCase.searchProductList("Рубашка Среда", onResponse, onError);
|
await useCase.searchProductList("Рубашка Среда", onResponse, onError);
|
||||||
});
|
});
|
||||||
|
test("GetProduct", () async {
|
||||||
|
await useCase.getProduct(_productId, onResponse, onError);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user