Files
sendico/frontend/pshared/lib/service/recipient/pmethods.dart
Stephan D e6b001dc61 fix
2025-12-11 01:30:28 +01:00

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);
}
}