add discount api
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/payment_method.dart';
|
||||
import 'package:fcs/domain/vo/message.dart';
|
||||
import 'package:fcs/helpers/api_helper.dart';
|
||||
@@ -32,4 +33,19 @@ class CommonDataProvider {
|
||||
payload: {"owner_id": ownerID, "seen_by_owner": seenByOwner},
|
||||
token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> createDiscount(Discount discount) async {
|
||||
return await requestAPI("/discounts", "POST",
|
||||
payload: discount.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> updateDiscount(Discount discount) async {
|
||||
return await requestAPI("/discounts", "PUT",
|
||||
payload: discount.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> deleteDiscount(String id) async {
|
||||
return await requestAPI("/discounts", "DELETE",
|
||||
payload: {"id": id}, token: await getToken());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:fcs/data/provider/common_data_provider.dart';
|
||||
import 'package:fcs/data/provider/user_data_provider.dart';
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/payment_method.dart';
|
||||
import 'package:fcs/domain/vo/message.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -37,4 +37,19 @@ class CommonServiceImp implements CommonService {
|
||||
Future<void> seenMessage(String ownerID, bool seenByOwner) {
|
||||
return commonDataProvider.seenMessage(ownerID, seenByOwner);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> createDiscount(Discount discount) {
|
||||
return commonDataProvider.createDiscount(discount);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteDiscount(String id) {
|
||||
return commonDataProvider.deleteDiscount(id);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateDiscount(Discount discount) {
|
||||
return commonDataProvider.updateDiscount(discount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/payment_method.dart';
|
||||
import 'package:fcs/domain/vo/message.dart';
|
||||
|
||||
@@ -10,4 +11,9 @@ abstract class CommonService {
|
||||
// Messaging
|
||||
Future<void> sendMessage(Message message);
|
||||
Future<void> seenMessage(String ownerID, bool seenByOwner);
|
||||
|
||||
// Payment
|
||||
Future<void> createDiscount(Discount discount);
|
||||
Future<void> updateDiscount(Discount discount);
|
||||
Future<void> deleteDiscount(String id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user