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 _basicService = BasicService( objectType: _objectType, fromJson: (json) => PaymentMethodResponse.fromJson(json).paymentMethods.map((dto) => dto.toDomain()).toList(), ); static BasicService get basicService => _basicService; static Future> list(String organizationRef, String recipientRef) async { return _basicService.list(organizationRef, recipientRef); } static Future get(String recipientRef) async { return _basicService.get(recipientRef); } static Future> create(String organizationRef, PaymentMethod paymentMethod) async { return _basicService.create(organizationRef, paymentMethod.toDTO().toJson()); } static Future> update(PaymentMethod paymentMethod) async { return _basicService.update(paymentMethod.toDTO().toJson()); } static Future> delete(PaymentMethod paymentMethod) async { return _basicService.delete(paymentMethod.storable.id); } }