Skip to content

Commit 079e070

Browse files
committed
fix: align single-file child payload with OpenAPI schema
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 961a55e commit 079e070

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

lib/Service/FileService.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,41 @@ private function syncSingleFileCollection(): void {
618618
'metadata' => $this->fileData->metadata,
619619
'totalPages' => $this->fileData->totalPages ?? 0,
620620
'pdfVersion' => $this->fileData->pdfVersion ?? '',
621-
'mime' => $this->fileData->mime ?? '',
622621
'size' => $this->fileData->size ?? 0,
623-
'signers' => $this->fileData->signers ?? [],
622+
'signers' => $this->mapSignerDetailsToSummary($this->fileData->signers ?? []),
624623
'file' => $this->urlGenerator->linkToRoute('libresign.page.getPdf', ['uuid' => $this->fileData->uuid]),
625624
],
626625
];
627626
}
628627

628+
/**
629+
* @param array<int, array<string, mixed>|object> $signers
630+
* @return array<int, array<string, mixed>>
631+
*/
632+
private function mapSignerDetailsToSummary(array $signers): array {
633+
return array_map(static function ($signer): array {
634+
$signerData = is_object($signer) ? (array)$signer : $signer;
635+
if (!is_array($signerData)) {
636+
return [];
637+
}
638+
639+
$summary = [
640+
'signRequestId' => $signerData['signRequestId'] ?? null,
641+
'displayName' => $signerData['displayName'] ?? '',
642+
'email' => $signerData['email'] ?? '',
643+
'signed' => $signerData['signed'] ?? null,
644+
'status' => $signerData['status'] ?? 0,
645+
'statusText' => $signerData['statusText'] ?? '',
646+
];
647+
648+
if (isset($signerData['identifyMethods']) && is_array($signerData['identifyMethods'])) {
649+
$summary['identifyMethods'] = $signerData['identifyMethods'];
650+
}
651+
652+
return $summary;
653+
}, $signers);
654+
}
655+
629656
private function computeEnvelopeSignersProgress(): void {
630657
if (!$this->file || $this->file->getParentFileId() || empty($this->fileData->signers)) {
631658
return;

0 commit comments

Comments
 (0)