Skip to content

[Feature]: Modify TransferDocument #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks
StanBarrows opened this issue Mar 21, 2025 · 0 comments
Open
3 tasks

[Feature]: Modify TransferDocument #188

StanBarrows opened this issue Mar 21, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@StanBarrows
Copy link
Contributor

StanBarrows commented Mar 21, 2025

Question or Feature?

<?php

namespace CodebarAg\DocuWare\Requests\Documents\ModifyDocuments;

use CodebarAg\DocuWare\Responses\Documents\ModifyDocuments\TransferDocumentResponse;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;

class TransferDocument extends Request implements HasBody
{
    use HasJsonBody;

    protected Method $method = Method::POST;

    public function __construct(
        protected readonly string $fileCabinetId,
        protected readonly string $destinationFileCabinetId,
        protected readonly string $storeDialogId,
        protected readonly string $documentId,
        protected readonly array $fields = [],
    ) {}

    public function resolveEndpoint(): string
    {
        return '/FileCabinets/'.$this->destinationFileCabinetId.'/Task/Transfer';
    }

    protected function defaultHeaders(): array
    {
        return [
            'Accept' => 'application/json',
            'Content-Type' => 'application/vnd.docuware.platform.documentstransferinfo+json',
            'X-Requested-With' => 'XMLHttpRequest',
        ];
    }

    protected function defaultBody(): array
    {
        return [
            'SourceFileCabinetId' => $this->fileCabinetId,
            'Documents' => [
                [
                    'Id' => $this->documentId,
                    'Fields' => $this->fields,
                ],
            ],
            'KeepSource' => false,
            'FillIntellix' => false,
            'UseDefaultDialog' => false,
        ];
    }

    public function createDtoFromResponse(Response $response): bool
    {
        return TransferDocumentResponse::fromResponse($response);
    }
}

  • Make StoreDialog optional
  • Allow to override these settings
'KeepSource' => false,
'FillIntellix' => false,
'UseDefaultDialog' => false,
  • Check for Fields Indexes/Array that are passed like in UpdateIndexValues
<?php

namespace CodebarAg\DocuWare\Requests\Documents\UpdateIndexValues;

use CodebarAg\DocuWare\DTO\Documents\DocumentIndex\PrepareDTO;
use CodebarAg\DocuWare\Exceptions\UnableToUpdateFields;
use CodebarAg\DocuWare\Responses\Documents\UpdateIndexValues\UpdateIndexValuesResponse;
use Illuminate\Support\Collection;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;

class UpdateIndexValues extends Request implements HasBody
{
    use HasJsonBody;

    protected Method $method = Method::PUT;

    /**
     * @throws UnableToUpdateFields
     */
    public function __construct(
        protected readonly string $fileCabinetId,
        protected readonly string $documentId,
        protected readonly ?Collection $indexes = null,
        protected readonly bool $forceUpdate = false,
    ) {}

    public function resolveEndpoint(): string
    {
        return '/FileCabinets/'.$this->fileCabinetId.'/Documents/'.$this->documentId.'/Fields';
    }

    public function defaultBody(): array
    {
        $body = [];

        if ($this->indexes) {
            $bodyEncode = json_encode(PrepareDTO::makeField($this->indexes));
            $bodyDecode = json_decode($bodyEncode, true);
            $body = $bodyDecode;
        }

        return $body;

    }

    public function createDtoFromResponse(Response $response): Collection
    {
        return UpdateIndexValuesResponse::fromResponse($response);
    }
}



@StanBarrows StanBarrows added the enhancement New feature or request label Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant