Изменение корзины-8
This commit is contained in:
parent
0233559bed
commit
a724d955e6
@ -141,4 +141,18 @@ class Client extends Repository {
|
||||
);
|
||||
return CartModel.fromJSON(response.data);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CartModel> editCart(CartModel cartModel) async {
|
||||
Response response = await dio.patch(
|
||||
"$apiUrl/collections/cart/records/${cartModel.id}",
|
||||
options: options,
|
||||
data: {
|
||||
"user_id": cartModel.userId,
|
||||
"product_id": cartModel.productId,
|
||||
"count": cartModel.count,
|
||||
},
|
||||
);
|
||||
return CartModel.fromJSON(response.data);
|
||||
}
|
||||
}
|
||||
|
@ -37,4 +37,6 @@ abstract class Repository {
|
||||
Future<ProjectModel> addProject(ProjectModel projectModel);
|
||||
|
||||
Future<CartModel> addCart(CreateCartModel createCartModel);
|
||||
|
||||
Future<CartModel> editCart(CartModel cartModel);
|
||||
}
|
||||
|
@ -128,4 +128,12 @@ class BaseUseCase {
|
||||
onError,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> editCart(
|
||||
CartModel cartModel,
|
||||
Function(CartModel) onResponse,
|
||||
Function(Exception) onError,
|
||||
) async {
|
||||
await helper.request(() => client.editCart(cartModel), onResponse, onError);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ final String _productId = "45urlx4rj907rrk";
|
||||
|
||||
void main() {
|
||||
group("Query", () {
|
||||
late CartModel cartModel;
|
||||
test("CreateUser", () async {
|
||||
late final AuthModel authModel;
|
||||
final String testEmail = "$testString@test.test";
|
||||
@ -96,6 +97,21 @@ void main() {
|
||||
test("AddCart", () async {
|
||||
await useCase.addCart(
|
||||
CreateCartModel(userId: _userId, productId: _productId, count: 7),
|
||||
(obj) {
|
||||
cartModel = obj;
|
||||
onResponse(obj);
|
||||
},
|
||||
onError,
|
||||
);
|
||||
});
|
||||
test("EditCart", () async {
|
||||
await useCase.editCart(
|
||||
CartModel(
|
||||
id: cartModel.id,
|
||||
userId: _userId,
|
||||
productId: _productId,
|
||||
count: 8,
|
||||
),
|
||||
onResponse,
|
||||
onError,
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user