updated document upload according to fresh api

This commit is contained in:
Arseni
2026-03-04 18:07:08 +03:00
parent aff804ec58
commit c59538869b
12 changed files with 122 additions and 53 deletions

View File

@@ -8,27 +8,27 @@ class PaymentDocumentsService {
static final _logger = Logger('service.payment_documents');
static const String _objectType = Services.payments;
static Future<DownloadedFile> getAct(
static Future<DownloadedFile> getOperationDocument(
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;
}
String gatewayService,
String operationRef,
) async {
final query = <String, String>{
'gateway_service': gatewayService,
'operation_ref': operationRef,
};
final queryString = Uri(queryParameters: query).query;
final url = '/documents/act/$organizationRef?$queryString';
_logger.fine('Downloading act document for payment $paymentRef');
final url = '/documents/operation/$organizationRef?$queryString';
_logger.fine(
'Downloading operation document for operation $operationRef in gateway $gatewayService',
);
final response = await AuthorizationService.getGETBinaryResponse(
_objectType,
url,
);
final filename =
_filenameFromDisposition(response.header('content-disposition')) ??
'act_$paymentRef.pdf';
'operation_$operationRef.pdf';
final mimeType = response.header('content-type') ?? 'application/pdf';
return DownloadedFile(
bytes: response.bytes,