38 lines
1.4 KiB
Dart
38 lines
1.4 KiB
Dart
import 'package:pshared/api/responses/payment_method.dart';
|
|
import 'package:pshared/data/mapper/payment/method.dart';
|
|
import 'package:pshared/models/payment/methods/type.dart';
|
|
import 'package:pshared/service/services.dart';
|
|
import 'package:pshared/service/template.dart';
|
|
|
|
|
|
class PaymentMethodService {
|
|
static const String _objectType = Services.paymentMethods;
|
|
|
|
static final BasicService<PaymentMethod> _basicService = BasicService<PaymentMethod>(
|
|
objectType: _objectType,
|
|
fromJson: (json) => PaymentMethodResponse.fromJson(json).paymentMethods.map((dto) => dto.toDomain()).toList(),
|
|
);
|
|
|
|
static BasicService<PaymentMethod> get basicService => _basicService;
|
|
|
|
static Future<List<PaymentMethod>> list(String organizationRef, String recipientRef) async {
|
|
return _basicService.list(organizationRef, recipientRef);
|
|
}
|
|
|
|
static Future<PaymentMethod> get(String recipientRef) async {
|
|
return _basicService.get(recipientRef);
|
|
}
|
|
|
|
static Future<List<PaymentMethod>> create(String organizationRef, PaymentMethod paymentMethod) async {
|
|
return _basicService.create(organizationRef, paymentMethod.toDTO().toJson());
|
|
}
|
|
|
|
static Future<List<PaymentMethod>> update(PaymentMethod paymentMethod) async {
|
|
return _basicService.update(paymentMethod.toDTO().toJson());
|
|
}
|
|
|
|
static Future<List<PaymentMethod>> delete(PaymentMethod paymentMethod) async {
|
|
return _basicService.delete(paymentMethod.storable.id);
|
|
}
|
|
}
|