2020-10-26 04:41:24 +06:30
|
|
|
import 'package:fcs/domain/entities/invoice.dart';
|
2020-10-28 05:11:06 +06:30
|
|
|
import 'package:fcs/domain/entities/payment.dart';
|
2020-10-26 04:41:24 +06:30
|
|
|
import 'package:fcs/helpers/api_helper.dart';
|
|
|
|
|
import 'package:fcs/helpers/firebase_helper.dart';
|
|
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
|
|
|
|
|
|
class InvoiceDataProvider {
|
|
|
|
|
final log = Logger('InvoiceDataProvider');
|
|
|
|
|
static final InvoiceDataProvider instance = InvoiceDataProvider._();
|
|
|
|
|
InvoiceDataProvider._();
|
|
|
|
|
|
|
|
|
|
Future<void> createInvoice(Invoice invoice) async {
|
|
|
|
|
return await requestAPI("/invoices", "POST",
|
|
|
|
|
payload: invoice.toMap(), token: await getToken());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> updateInvoice(Invoice invoice) async {
|
|
|
|
|
return await requestAPI("/invoices", "PUT",
|
|
|
|
|
payload: invoice.toMap(), token: await getToken());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> cancelInvoice(Invoice invoice) async {
|
|
|
|
|
return await requestAPI("/invoices/cancel", "PUT",
|
|
|
|
|
payload: {"id": invoice.id}, token: await getToken());
|
|
|
|
|
}
|
2020-10-28 05:11:06 +06:30
|
|
|
|
|
|
|
|
Future<void> pay(Payment payment) async {
|
|
|
|
|
return await requestAPI("/invoices/pay", "PUT",
|
|
|
|
|
payload: payment.toMap(), token: await getToken());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> updatPaymentStatus(Payment payment) async {
|
|
|
|
|
return await requestAPI("/invoices/pay/status", "PUT",
|
|
|
|
|
payload: payment.toMap(), token: await getToken());
|
|
|
|
|
}
|
2020-10-26 04:41:24 +06:30
|
|
|
}
|