22
33namespace CodebarAg \DocuWare \Requests \Documents \ModifyDocuments ;
44
5+ use CodebarAg \DocuWare \DTO \Documents \DocumentIndex \PrepareDTO ;
56use CodebarAg \DocuWare \Responses \Documents \ModifyDocuments \TransferDocumentResponse ;
7+ use Illuminate \Support \Collection ;
68use Saloon \Contracts \Body \HasBody ;
79use Saloon \Enums \Method ;
810use Saloon \Http \Request ;
@@ -18,9 +20,12 @@ class TransferDocument extends Request implements HasBody
1820 public function __construct (
1921 protected readonly string $ fileCabinetId ,
2022 protected readonly string $ destinationFileCabinetId ,
21- protected readonly string $ storeDialogId ,
2223 protected readonly string $ documentId ,
23- protected readonly array $ fields = [],
24+ protected readonly ?string $ storeDialogId = null ,
25+ protected readonly ?Collection $ fields = null ,
26+ protected readonly bool $ keepSource = false ,
27+ protected readonly bool $ fillIntellix = false ,
28+ protected readonly bool $ useDefaultDialog = false ,
2429 ) {}
2530
2631 public function resolveEndpoint (): string
@@ -39,18 +44,30 @@ protected function defaultHeaders(): array
3944
4045 protected function defaultBody (): array
4146 {
42- return [
47+ $ body = [
4348 'SourceFileCabinetId ' => $ this ->fileCabinetId ,
4449 'Documents ' => [
4550 [
4651 'Id ' => $ this ->documentId ,
47- 'Fields ' => $ this ->fields ,
4852 ],
4953 ],
50- 'KeepSource ' => false ,
51- 'FillIntellix ' => false ,
52- 'UseDefaultDialog ' => false ,
54+ 'KeepSource ' => $ this -> keepSource ,
55+ 'FillIntellix ' => $ this -> fillIntellix ,
56+ 'UseDefaultDialog ' => $ this -> useDefaultDialog ,
5357 ];
58+
59+ // Add storeDialogId if provided
60+ if ($ this ->storeDialogId ) {
61+ $ body ['StoreDialogId ' ] = $ this ->storeDialogId ;
62+ }
63+
64+ // Add fields if provided
65+ if ($ this ->fields ) {
66+ $ fieldData = PrepareDTO::makeField ($ this ->fields );
67+ $ body ['Documents ' ][0 ]['Fields ' ] = $ fieldData ['Field ' ];
68+ }
69+
70+ return $ body ;
5471 }
5572
5673 public function createDtoFromResponse (Response $ response ): bool
0 commit comments