SEND063
This commit is contained in:
@@ -4,17 +4,30 @@ import 'package:pshared/models/file/downloaded_file.dart';
|
||||
import 'package:pshared/service/authorization/service.dart';
|
||||
import 'package:pshared/service/services.dart';
|
||||
|
||||
|
||||
class PaymentDocumentsService {
|
||||
static final _logger = Logger('service.payment_documents');
|
||||
static const String _objectType = Services.payments;
|
||||
|
||||
static Future<DownloadedFile> getAct(String organizationRef, String paymentRef) async {
|
||||
final encodedRef = Uri.encodeQueryComponent(paymentRef);
|
||||
final url = '/documents/act/$organizationRef?payment_ref=$encodedRef';
|
||||
static Future<DownloadedFile> getAct(
|
||||
String organizationRef,
|
||||
String paymentRef, {
|
||||
String? operationRef,
|
||||
}) async {
|
||||
final query = <String, String>{'payment_ref': paymentRef};
|
||||
final operationRefValue = operationRef;
|
||||
if (operationRefValue != null && operationRefValue.isNotEmpty) {
|
||||
query['operation_ref'] = operationRefValue;
|
||||
query['operationRef'] = operationRefValue;
|
||||
}
|
||||
final queryString = Uri(queryParameters: query).query;
|
||||
final url = '/documents/act/$organizationRef?$queryString';
|
||||
_logger.fine('Downloading act document for payment $paymentRef');
|
||||
final response = await AuthorizationService.getGETBinaryResponse(_objectType, url);
|
||||
final filename = _filenameFromDisposition(response.header('content-disposition')) ??
|
||||
final response = await AuthorizationService.getGETBinaryResponse(
|
||||
_objectType,
|
||||
url,
|
||||
);
|
||||
final filename =
|
||||
_filenameFromDisposition(response.header('content-disposition')) ??
|
||||
'act_$paymentRef.pdf';
|
||||
final mimeType = response.header('content-type') ?? 'application/pdf';
|
||||
return DownloadedFile(
|
||||
|
||||
Reference in New Issue
Block a user